You need to sign in to do that
Don't have an account?
Eugena Nelson 1
Opportunity validation rule for a checkbox
Would anyone have a validation rule for the following:
A rule will trigger when trying to close won an opportunity. It can only be closed won if a checkbox is true.
A rule will trigger when trying to close won an opportunity. It can only be closed won if a checkbox is true.
Can you explain you are query little more, If checkbox is True from same object?
if checkbox is true then user should able to select closed won stage only right?
I just tried in my org and its working as per your requirement,
Checkbox api name i taken private checkbox in opportunity,You can replace with your checkbox and write this trigger on opportunity object
trigger OpportunityTrigger on Opportunity (before insert,before update) {
if(Trigger.isBefore && (Trigger.isInsert || Trigger.isUpdate)){
for(Opportunity opp:Trigger.New){
if(opp.IsPrivate==true){
if(opp.StageName !='Closed Won'){
opp.StageName.addError('Stage should be closed won if Private is checked');
}
}
}
}
}
This validation will work on creation of new opportunity or updating existing opportunity
Hope this helps ,If it helps please mark this as best answer
Thank you
Bhagyasri sreenadhu
Thank you for you help. I tried this validation rule and it gives me a syntax error, "extra opportunity trigger"
You have to create a trigger class and use this code for validation.
Not from validationrule
Thank you
Bhagyasri
Previously I written Trigger code for validation,If you need validation rule only then you can use below code in validation rules of object(opportunity)
And Here I taken my checkbox isprivate,Instead you can give your api name of your checkbox
AND( IsPrivate == true,
!ISPICKVAL(StageName, 'Closed Won') )
Error Message you can give as per your requirement
Hope it solves your issue,I also tried in my org its working
If it helps,Please mark this as best answer!!
Thank you
Bhagyasri
Eugena Nelson 1
Yes you are right!! You can do this with Validation rules and you can do in other ways as well like Flows,Triggers..etc
Intially I given code for trigger then as you need validation rule i posted validation rule as well as below
AND( IsPrivate == true,
!ISPICKVAL(StageName, 'Closed Won') )
This works ,If you have any requirement you can use this.Hope this helps
Thank you
Bhagyasri
I Thought if checkbox is checked then stage should be closed won,Try below one for if user selected closed won stage and not selected check box
AND( ISPICKVAL(StageName, 'Closed Won'),
IsPrivate = false)
replace isPrivate with your checkbox api
Could you verify if the API Name of '100% - BOOKED' is infact that value or is it 'Closed/Won' ? You should give the API name of the picklist value in the formula.
Nikhil
Stage NAme you given 100%-Booked, Is it your expected stage?