+ Start a Discussion
:) :) :) :) :):) :) :) :) :) 

Last Accessed By field

Hello,

 

We have Created By and Last Modified By fields by default but Is there any way in salesforce that we can create Last Accessed By using some sort of Session or custom APEX code.

 

Thanks!



hisalesforcehisalesforce

You can use create one more field.

You can use either trigger or workflow to set that field.

You have to check whether lasmodifiedby standard field is  change or not .If change set your field.

 

 

 

:) :) :) :) :):) :) :) :) :)

I can't use Trigger because trigger only fires when any DML operation happens but here I am just looking the name of the uses who recently viewed this record. I might need to use recentlyviewd object to get that data.

 

SOQL Query for RecentlyViewed Items

Select Id, type, Alias, email, firstname, lastname, IsActive, LastReferencedDate, LastViewedDate, Name, phone, profileid, title, UserRoleID From RecentlyViewed

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_recentlyviewed.htm

 

But I couldn't find the user id or user name who recently viewed this records

 

 

hisalesforcehisalesforce

You can get the userid by doing soql in user object from the alias name.

But I am still not sure how the event will happen  to update the record.

Either you need to use batch apex or schedule class.