FOR VIEW IN SOQL
When we are viewing any record in salesforce, that records
are going to be tagged in recent items.
First question in my mind, how this
records are referring in recent items.
The answer for this is, in each record
there is a field as LastViewedDate and there is one
object named as RecentlyViewed(standard object) in salesforce. So whenever we are
viewing any records/opening the details
of the record, LastViewedDate getting updated for that record and a new record
creating in the RecentlyViewed Object. we can see this standard object in developer console as below screen shot.
But now if I will write any soql to view/Fetch
record, how can I add that fetched records in Recent Items?
There is an easiest solution in salesforce for this, so whenever
you are fetching any record using SOQL, simply use FOR VIEW clause to notify
salesforce that the record is being viewed and add this in recentlyViewed
object and update the LastViewedDate field of that record.
Assume there is one record in Account object with name as 'sForce
updated. updated. Updated’
lets see if I am writing any soql without using FOR VIEW, cannot get that fetched record in recently viewed records.
Now I am writing same SOQL with using FOR VIEW Clause, we can get this record in Recently viewed record.
Ex: select id,name
from Account where name='sForce updated. updated. updated.' FOR VIEW
Next Topic: FOR REFERENCE IN SOQL
No comments:
Post a Comment