Salesforce native Audit feature tracks only if a record is modified. What is the best way to store the Record View Audit ?
Would need to store which Case record was viewed, and who viewed them.
What`s the bext way to achieve this ?
Hi Bharath,
OPTION 1 :
You can do this by a custom solution:
(i) Create a field on the Custom Object say 'Record View Count(Record_View_Count__c)' of type - Number(18,0).
(ii) Then create a Visualforce Page like this:
Label: Record View Tracker
Name: RecordViewTracker
<apex:page standardController="Case">
<apex:includeScript value="/soap/ajax/28.0/connection.js"/>
<script type="text/javascript">
sforce.connection.sessionId = '{!GETSESSIONID()}';
var object = new sforce.SObject('Case');
object.Id = "{!Case.Id}";
object.Record_View_Count__c = {!Case.Record_View_Count__c} + 1;
var result = sforce.connection.update([object]);
if(result[0].success != 'true'){
alert('Could not Update the Record View Tracking Information. \r\nError: ' + result[0].errors.message);
}
</script>
</apex:page>
(iii) Then go to the Page Layout(say the Cases for now) > Edit It > Select Visualforce Pages from the Page Host > Drag our new 'RecordViewTracker' on to the Page Layout > Click on the Wedge Icon > Set Height: 0 and Width: 0(so that it is not displayed on the Page).
(iv) Save it.
Working: Whenever someone views the record via the Salesforce UI, then the JavaScript within the In-line Visualforce Page will be executed and the Record View Count on the Oppty record will incremented by 1. Also, you need not put the Record View Count field on the Page Layout.
Now, if you want it on an another Custom Object/Standard Object just do these:
(i) Find and Replace 'Case' with the API Name of that object of concern.
(ii) Make sure you have created the Record View Count field on that Custom Object.
(iii) Drag it to the Page Layout too.
Option 2:
Appexchange:
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000055aKGEAY