You need to sign in to do that
Don't have an account?
nikki sharon
hi guys im new to salesforce. i have been trying to do a trigger or validation rule to skip stage in opportunity in case that the checkbox is checked and i couldn't manage to do it. any ideas?
trigger
trigger skipStage on Opportunity (before update,after update) {
if(opp.Customer_confirms__c== true && opp.StageName== 'Negotiation/Review'){
opp.StageName = 'Closed won';
}
else{opp.StageName = 'Proposal/Price Quote';
}
or validation rule
IF(AND(Customer_confirms__c==true,
ISPICKVAL(PRIORVALUE(StageName),"Negotiation/Review")),
ISPICKVAL(PRIORVALUE(StageName),"Closed won"),
ISPICKVAL(PRIORVALUE(StageName),"Proposal/Price Quote"))
}
trigger skipStage on Opportunity (before update,after update) {
if(opp.Customer_confirms__c== true && opp.StageName== 'Negotiation/Review'){
opp.StageName = 'Closed won';
}
else{opp.StageName = 'Proposal/Price Quote';
}
or validation rule
IF(AND(Customer_confirms__c==true,
ISPICKVAL(PRIORVALUE(StageName),"Negotiation/Review")),
ISPICKVAL(PRIORVALUE(StageName),"Closed won"),
ISPICKVAL(PRIORVALUE(StageName),"Proposal/Price Quote"))
}
Don't use the validation rule for this scenario.
You have to write the trigger like below:
trigger skipStage on Opportunity (before update) {
for(Opportunity opp : trigger.new)
{
if(opp.Customer_confirms__c == true && opp.StageName=='Negotiation/Review'){
opp.StageName = 'Closed won';
}
else
{
opp.StageName = 'Proposal/Price Quote';
}
}
}
Thanks,
Maharajan.C
there is no error message but its still moving in the regular way between the stages, what i want is that if im doing checked so the next stage will be the last one. now its not doing anything.am i clear?
thank u so much for your help
For me it's working.
1. Check the trigger is Active.
2. The above code will works only in Opportunity Update. If you want this to work on Opportunity creation also then add the before insert in below line.
trigger skipStage on Opportunity (before insert ,before update)
3. For existing records please simply edit the record once.
Thanks,
Maharajan.C