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
Ashley ShealeyAshley Shealey 

Tracking when a link/url on a custom object is clicked.

I am looking for a simple solution to track when a custom url field is clicked on a record. I have a custom object with several URL's (URL Fields with default values) that link to Documents that also reside in Salesforce. I would like to track when a user clicks the link and reads the document. Any suggestions?
I can't think of any simple solution.
Complex solution is to open a vf page instead of the document and in that vf page you can track the user and then redirect to the document.
Ashley ShealeyAshley Shealey
I'm new to visual force. Does anyone have a sample code that would redirect to a URL and update a field on the record once it redirects?
Try to create a custom button with this javascript:
var po = new sforce.SObject("Case"); = "{!Case.Id}"; 
var currentUser = sforce.connection.getUserInfo();
po.GSR__DocumentOpenedBy__c = currentUser.userId; 
result = sforce.connection.update([po]);'/0159000000ClUuV');

Here, I am using Case object and updating a lookup field DocumentOpenedBy__c with the logged in user's id and then redirecting to a document