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
divya1234divya1234 

what is the way to update the field in system mode

I have a two lookup field on opportunity object  i want to update lookup1 field if lookup2 (owner) field gets updated but i want this field to update in user mode not in system mode , since my lookup2 field is owner field i want to assign the record owner o only those user who have read access to the record . i tried with trigger and process builder  both are running in system mode.i tried to create with sharing class and call that class in trigger ..but that is also running in systme mode...
can somebody please help me with other ideas
Khan AnasKhan Anas (Salesforce Developers) 
Hi Divya,

Greetings to you!

You can use Flows as it runs in user mode. Here is the mode of execution:
  • Trigger - System
  • Validation Rule - System
  • Auto-Response Rule - System
  • Assignment Rule - System
  • Workflow Rule - System
  • Escalation Rule - System
  • All Types of calculation behind formula, Rollup Summary - System
  • Process Builder - System
  • Visual Workflow or flow - User
    • if flow is called from Process Builder - System
    • if flow is called from Workflow - System
    • if flow is called from Apex - (depends on with or w/o sharing of apex class)
    • if flow is called from Custom Button - System
    • if flow is embed in Visualforce - Depends on VFP context
    • if flow is called from REST API - System
  • Approval Process - System
  • Publisher Action - System
  • InvocableMethod
    • if this is called from flow - User
    • if this is called from Process Builder (does it depends on with or without sharing is specified on that Class) - System
    • if this is called from REST API - (depends on with or w/o sharing of the class)
  • Custom Button - System
  • Test method with System.runAs() - User
  • Test method without System.runAs() - System
  • Visualforce Page (StandardController) - User
  • Visualforce Page (StandardController with extension) - System
  • Visualforce Page (Custom Controller)
    • depends on with or without sharing of the controller
  • Visualforce Component - depends on Visualforce page where it is used
  • Macros - System
  • Annonymous Apex - User
  • Chatter in Apex - User
  • Email Service - User
  • All types of Jobs - System
  • Apex Webservices (SOAP API and REST API) - System (Consequently, the current user's credentials are not used, and any user who has access to these methods can use their full power, regardless of permissions, field-level security, or sharing rules.)

Reference: https://salesforce.stackexchange.com/questions/172060/types-of-execution-system-mode-or-user-mode

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas