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
NaishadhNaishadh 

Is there any way to indentify record is updated in same cycle?

Hi,

 

In my lead object I have two field. email and emailoptout. I want to update all related lead and contact records when I update any lead and contact emailloptout field value. I tried to do so but it goes in infinite loop. Is there any way or through api we can check that record is already udpated or not?

 

Please guide.

Best Answer chosen by Admin (Salesforce Developers) 
wesnoltewesnolte

Unfortunately not. Their docs recommend using a static utility class.

 

Wes

All Answers

wesnoltewesnolte

Hey

 

Are you using triggers? If so you'll need to create a boolean static variable, perhaps in a utility class then in your trigger perform the necesary logic around this var e.g.

 

trigger myTrigger on Lead(after insert){

 

  if(!UtilClass.hasRun){

  // perform logic here

  UtilClass.hasRun = true;

}

 

Cheers,

Wes 

NaishadhNaishadh

Hi,

 

Thanks for reply.  Yes I am using trigger but as per my current requirements, when user update lead record it should also update all related leads. So it again call lead trigger. 

 

Currently, I am storing Ids in utility class Set but I want to know is there any default feature for the same provided by salesforce?

wesnoltewesnolte

Unfortunately not. Their docs recommend using a static utility class.

 

Wes

This was selected as the best answer