You need to sign in to do that
Don't have an account?

I need to have a code which counts the no of times the record has been accessed , please give logic
hi all ,
need to have a code which counts the no of times the record has been accessed , please give logic or code I need to complete
Thanks
need to have a code which counts the no of times the record has been accessed , please give logic or code I need to complete
Thanks
https://salesforcemonk.wordpress.com/2018/03/20/record-visit-counter/
All Answers
https://salesforcemonk.wordpress.com/2018/03/20/record-visit-counter/
<apex:page extensions="StandardControllerExtension" action="{!updateCounter}" showheader="false" sidebar="false" standardcontroller="Account"></apex:page>
Add this page to the Account page layout
Controller:
public class StandardControllerExtension {
List<Account> accList;
@TestVisible
Id accID;
private final Account acct;
public StandardControllerExtension(ApexPages.standardController stdController){ acct = (Account)stdController.getRecord();
accId = acct.Id;
}
public void updateCounter(){
accList = [SELECT Id, Record_Visit_Counter__c FROM ACCOUNT WHERE Id = :accID];
for(Account a : accList){
a.Record_Visit_Counter__c += 1;
}
update accList;
}
}