You need to sign in to do that
Don't have an account?

calling trigger only one time, if the trigger is new
in my Scenario, i have picklist field called status, in that picklist field i have multiple values. when i select the picklist field status='approved' and click on the save button then my trigger will run.
here is my trigger:
for (genesis__Applications__c app1: Trigger.new)
{
if(app1.genesis__Status__c == 'Approved')
{
application.getDetails(app1.Id);
}
}
my requirement is like: this trigger i need to call one time when the trigger is new, suppose if select the status=approved two times and clicking save button, i am getting the result two times with same values.for second time calling the trigger i want to check the trigger whether it is old or new. if it is new , then my class method i need to cal.if it is old then that method no need to cal. can any help me out from this scenario
here is my trigger:
for (genesis__Applications__c app1: Trigger.new)
{
if(app1.genesis__Status__c == 'Approved')
{
application.getDetails(app1.Id);
}
}
my requirement is like: this trigger i need to call one time when the trigger is new, suppose if select the status=approved two times and clicking save button, i am getting the result two times with same values.for second time calling the trigger i want to check the trigger whether it is old or new. if it is new , then my class method i need to cal.if it is old then that method no need to cal. can any help me out from this scenario
This trigger will fired only in before insert event .
Let me know if you need any help regarding this.
Thanks,
Vijay
if(trigger.isUpdate && trigger.isAfter)
{
for (genesis__Applications__c app1: Trigger.new)
{
if(app1.genesis__Status__c == 'Approved')
{
application.getDetails(app1.Id);
}
}
}
but my requirement is: for second time clicking save button with status=approved. i dont want to call this method.
for first time saving, i am getting some result. for second time also i am getting same result.
Try the below code it will work one time only,
Thanks,
Vijay
public Class checkRecursive{
private static boolean run = true;
public static boolean runOnce(){
if(run){
run=false;
return true;
}else{
return run;
}
}
}
Use the trigger and apex class both.
Hi,
check this condition it will work.you can have a Checkbox , whenever you are inserting make this checkbox value = true.
yes..
Hi,
Please select the best answer so it should be helpful to others.
Thanks,
Abhishek