function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kj Smithkj Smith 

Display a counter increment for each object record

I am displaying a vf report for each of object records created for the Report__c object(vf button on each report to generate the report), and I need to display a incrementing counter in front of each object record name in each report generated. Following is my controller and the vf page, currently my counter does not increment depending on the new reports created, any help on this is appreciated! or is there any other good way of doing this ?

Apex Controller-------------------
public with sharing class PDFGeneratorController { public Report__c report {get; set;}
public Id reportId; Integer counter = 0;

public PDFGeneratorController(ApexPages.StandardController controller) {
reportId = controller.getRecord().Id;
report = [SELECT Id, Name, Actions__c, C_Status__c, Status_Reason__c, Status__c, Status_Indicator__c, Reason__c, Notes__c, for_Next_Week__c, Project__r.Name, Summary__c, S_Status__c, S_Reason__c, Week_Ending__c, Counter__c FROM Report__c WHERE Id =: reportId LIMIT 1];

//Counter__c is a number field created on the object(don't know if this logic is right)
if(report.Counter__c != null)
counter = integer.valueOf(report.Counter__c);
}

public void incrementCounter() {
counter++;
report = [Select id, Name from Report__c ]; report.Counter__c = counter;
update report;
}

public Integer getCount() {
return counter;
  }
}

VF Page--------- Counter should be displayed in the header with the report name as follows
<apex:sectionHeader title ="Weekly Report :{!Report__c.Name} {!count}"/>


 
Shashikant SharmaShashikant Sharma
Could you elaborate this Report Object and the over all functionality that you want. Just one thing before you share more details in case you are looking for auto update of this VFP from actions out side in the org then you may want to look at Streaming APIs push notifications. You could read more http://blog.terrasky.com/quick-tips-on-streaming-api-for-salesforce-developers