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
janeisaacjaneisaac 

Validation rule with AND and OR statements not working

I have a VR written to require the user to enter the Contract Term # of Months, once the opportunity in a particular record type reaches a certain stage (stage 6) or higher.

 

However, its not working - any ideas?

Here is the formula as it stands now:

 

AND (
OR (
ISPICKVAL(StageName, "6 - Proposal/MOU Presented"),
ISPICKVAL(StageName, "7 - Verbal Acceptance"),
ISPICKVAL(StageName, "8 - Contract Sent/Negotiations"),
ISPICKVAL(StageName, "9 - Contract Executed"),
ISPICKVAL(StageName, "10 - Contract Validated "),
ISPICKVAL(StageName, "11 - Internal Kickoff Completed"),
ISPICKVAL(StageName, "12 - Customer Kickoff Completed"),
ISPICKVAL(StageName, "13 - Integration Instructions Sent"),
ISPICKVAL(StageName, "14 - Certification Complete"),
ISPICKVAL(StageName, "15 - Approved for Production"),
ISPICKVAL(StageName, "16 - Launched to Production")),
RecordType.Id="01280000000Luw9AAC",
ISBLANK(Contract_Term_Months__c)
)

 

 

Best Answer chosen by Admin (Salesforce Developers) 
janeisaacjaneisaac
Ahhh, I needed to use the API name of the Record Type - "Regional_Merchant" and now it works



[cid:image007.png@01CE8C46.A8466C70]

Jane Isaac
Director, Digital Global Sales Operations
w 401.886.4052
m 401.447.7745
digital.incomm.com
[cid:image002.png@01CE7E54.1D796250] [cid:image003.png@01CE7E54.1D796250] [cid:image004.png@01CE7E54.1D796250]

All Answers

crop1645crop1645
see http://boards.developerforce.com/t5/Product-Discussion/Validation-Rule-using-record-type-id/td-p/128786

Also, your use of recordtype.id is curious as the field in the Oppo is recordtypeId. So I did an experiment and it seems you can refer to recordtype.developername = 'foo' and thus avoid the hard coded ids which are not very transparent for maintenance

note that debugging VR can be done using debug logs which are handy way to see if the values in your object are what you expect

janeisaacjaneisaac
OK, so I tried it with the Record Type.developer name (see below). I even tried the ISNULL instead of ISBLANK since this is a number field but no luck.
I double checked the fields (stage name) to make sure I had typed it in exactly - the one I am testing is at Stage 8 and the field Contract Term # of Months is empty.

Any other ideas?



AND (
OR (
ISPICKVAL(StageName, "6 - Proposal/MOU Presented"),
ISPICKVAL(StageName, "7 - Verbal Acceptance"),
ISPICKVAL(StageName, "8 - Contract Sent/Negotiations"),
ISPICKVAL(StageName, "9 - Contract Executed"),
ISPICKVAL(StageName, "10 - Contract Validated "),
ISPICKVAL(StageName, "11 - Internal Kickoff Completed"),
ISPICKVAL(StageName, "12 - Customer Kickoff Completed"),
ISPICKVAL(StageName, "13 - Integration Instructions Sent"),
ISPICKVAL(StageName, "14 - Certification Complete"),
ISPICKVAL(StageName, "15 - Approved for Production"),
ISPICKVAL(StageName, "16 - Launched to Production")),
RecordType.DeveloperName = "Regional Merchant",
ISNULL(Contract_Term_Months__c)
)
Justine HeritageJustine Heritage

I've worked through this logic a couple of times and I don't see a problem... what you have written is logically equivalent to saying something like "if the record type is x and the stage is greater than or equal to six, then the Contract_term_months_c field must be filled." Is there any case you can find where the rule does fire?

janeisaacjaneisaac
Ahhh, I needed to use the API name of the Record Type - "Regional_Merchant" and now it works



[cid:image007.png@01CE8C46.A8466C70]

Jane Isaac
Director, Digital Global Sales Operations
w 401.886.4052
m 401.447.7745
digital.incomm.com
[cid:image002.png@01CE7E54.1D796250] [cid:image003.png@01CE7E54.1D796250] [cid:image004.png@01CE7E54.1D796250]
This was selected as the best answer
crop1645crop1645

Jane - please mark as solved; also note that SFDC encourages ISBLANK() rather than ISNULL() as best practice.