Development questions
How does the FOR VIEW and FOR REFERENCE clause work in SOQL?
FOR VIEW updates the LastViewedDate of the returned records so they show up in the user's Recently Viewed list. FOR REFERENCE updates LastReferencedDate (the record was referenced, e.g. in a lookup, without being viewed).
They are used to track usage so records appear in recent items and lookups.
soql
SELECT Id, Name FROM Account WHERE Id = :accId FOR VIEW
The data lives on the RecentlyViewed object (LastViewedDate, LastReferencedDate).
soqlkeywords
More Development questions
- What is an Apex Trigger in Salesforce and when should you use it over Flows?
- What is the difference between before triggers and after triggers?
- Explain all Trigger context variables (isInsert, isUpdate, isDelete, isUndelete, isBefore, isAfter, isExecuting, size, operationType).
- What is the difference between Trigger.new and Trigger.old?
- In which trigger events are Trigger.new and Trigger.newMap available?
- In which trigger events are Trigger.old and Trigger.oldMap available?