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
msreekmmsreekm 

trigger question (data sharing)

User A is inserting a lead ,which executes LeadsTrigger . LeadsTrigger get all leads with the following code-  "select id from leads".  Q:Will this soql get all the leads  or only the leads below User A's role heirarchy. Also can UserA update a lead belonging to UserB (owner).

 

If this is the case  how do we have a logic that will check against all lead records (for eg. de-duping)

 

Thanks,

Sree

 

Best Answer chosen by Admin (Salesforce Developers) 
gm_sfdc_powerdegm_sfdc_powerde
Triggers run in system context.  So your SOQL should bring all leads. 

All Answers

gm_sfdc_powerdegm_sfdc_powerde
Triggers run in system context.  So your SOQL should bring all leads. 
This was selected as the best answer
Cool_DevloperCool_Devloper

Yes, userA can edit the lead record whose owner is UserB, but only if he has the required CRED permissions!

Also, he can view the record as per the role hierarchy or sharing rules defined!

So, in case you want to run a de-dup logic on update/insert, you can do it through the trigger as it executes in the system mode.So, you have to check the duplicacy with all the existing data!

Cool_D