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
hramanihramani 

trigger condition requirement

Opportunity has a child object named products.
A trigger(first trigger) is written on Product where, when the Product is edited and updated, it updates the opportunity record too.
I have another trigger (second trigger) on opportunity which calls a particular method of a particular class.
Now because of the first trigger, Opportunity undergoes updation everytime a product record is edited as a result of which my second trigger calls the method.
I want my second trigger to call themethod of the class only when i edit the opportunity but not when the (child record) product is edited.
Now how do i give the condition inside the second trigger.

hitesh90hitesh90

Hi hramani,

 

You have to take one static boolean variable in one apex class.

and use that Static variable in your trigger for conditional calling.

set true or false value of that static variable in your apex trigger.

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other benefits.

Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
My Blog:- http://mrjavascript.blogspot.in/

hramanihramani

I have a check box at opportunity level which is by default unchecked. In the trigger on opportunity i have given condition where the method of class is invoked only when the checkbox is unchecked. now lets say the checkbox is unchecked and the product is edited and updated, now what happens is that the opportunity record also goes for updation invoking the trigger and calling the method. I don want this to happen. even after the product updation, only if edit and save the opportunity the class should be called for the trigger.  Pls help. It's pretty urgent.

digamber.prasaddigamber.prasad

Hi,

 

Assuming name of checkbox on opportunity is "Trigger_Check__c", your condition inside opportunity should be something like below:-

 

if(opp.Trigger_Check__c == false && opp.Trigger_Check__c != trigger.oldMap.get(opp.Id).Trigger_Check__c){
	//code comes here
}

 You can always make changes into above code as per your requirement. Let me know if you have any question about above.

 

Happy to help you!