+ 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?
SalesFORCE_enFORCErSalesFORCE_enFORCEr
I can't think of any simple solution.
SalesFORCE_enFORCErSalesFORCE_enFORCEr
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?
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Try to create a custom button with this javascript:
{!REQUIRESCRIPT("/soap/ajax/37.0/connection.js")} 
var po = new sforce.SObject("Case"); 
po.id = "{!Case.Id}"; 
var currentUser = sforce.connection.getUserInfo();
po.GSR__DocumentOpenedBy__c = currentUser.userId; 
result = sforce.connection.update([po]); 
window.open('/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