You need to sign in to do that
Don't have an account?
Validation Rule for Opportunity
I need to create a VR for the following:
Ig opportunity stage is and higher(picklist), then field Supplier (picklist) becomes required(can not be null), but for certain profiles and product preselection only (picklist).
Here is what I have:
AND (OR(ISPICKVAL( Product_Preselection__c ,"A"),(ISPICKVAL(Product_Preselection__c ,"Be")),OR( ISPICKVAL(StageName ,"7.2 Closed Lost"),ISPICKVAL(StageName ,"7.1 Closed Won"), ISPICKVAL(StageName ,"7.3 Qualified Out"), ISPICKVAL(StageName ,"6. Contract Sent"), ISPICKVAL(StageName ,"5. Contract Drafted")),
OR(
($User.ProfileId = "PrifileID 1"),($User.ProfileId ="PrifileID 2"),( $User.ProfileId = "PrifileID 3"),($User.ProfileId ="PrifileID 4")),
ISPICKVAL( Supplier__c , "")))
The formula passed syntax check, but when I activate it I have the following:
1. Instead of specified product preselections it works for ALL of them.
2. Even when Supplier is selected, the same error message appears- "Please add Supplier".
3. As a result, opportunity can not be saved
"Supplier" field is a dependent field on Product Preselection and has picklist values only for two product preselections specified in the VR. Other Product Preselection values don't have any dependent picklist values in the Supplier field.
Not sure if it's relevant.
Thanks!
I have not understood the requirement yet, but the code seems wrong.
For example, the 'AND' in the beginning of your code is meaningless because there's only 1 operand in the 'AND()' function.
To make it clear I organised your code:
This equals to:
Review your code.
Thanks. I tried your code, but got the same error.
In the previous post I just re-wrote your code in other ways, so the function of those codes cannot be different.
I meant to show that your code seemed not to meet your requirement whatever it might be.
I couldn't understand the description in your first post well.
Note that a record will become ERROR when VR condition is TRUE on the record.
My colleague suggested another approach. We created a field that's visible for admins only, it's a checkbox. When stage = 5 or greater,then this box is updated with True(workflow rule).
In the VR we use now, if field "Checkbox"=True, then the rule works.
It works fine until I add profile condition. Then I have the same problem as before. I can post a code, if it helps.