You need to sign in to do that
Don't have an account?
kjun
Validation Rule not working correctly when a recordtypeId is introduced
Hello,
Validation Rule to stop record from saving when a picklist value is blank fires, but not on the correct stage selection.
Use case:
Opportunity Object, has 6 record types (Group, Branch, Vendor, Client, Guest, Ti In Progress)
If the Opportunity RecordTypeId is “0122E000000iFFKQA2”
and the StageName Picklist is “Ti In Progress", a value from the picklist named, Resolution Type, must have a value selected prior to saving the record. If the Resolution Type picklist is left blank, the validation rule should error out the save attempt.
The VR I created is firing but not when the stage = Ti In Progress. I can select a different stage, prior to reaching Ti In Progress and the record errors out. .
I created this VR, tested it, and found not syntax errors. I was able to save the record even when the Resolution Type picklist was left blank. It should have prompted me to select a value from the picklist.
Any help on this would be appreciated!
Thanks
Validation Rule to stop record from saving when a picklist value is blank fires, but not on the correct stage selection.
Use case:
Opportunity Object, has 6 record types (Group, Branch, Vendor, Client, Guest, Ti In Progress)
If the Opportunity RecordTypeId is “0122E000000iFFKQA2”
and the StageName Picklist is “Ti In Progress", a value from the picklist named, Resolution Type, must have a value selected prior to saving the record. If the Resolution Type picklist is left blank, the validation rule should error out the save attempt.
The VR I created is firing but not when the stage = Ti In Progress. I can select a different stage, prior to reaching Ti In Progress and the record errors out. .
I created this VR, tested it, and found not syntax errors. I was able to save the record even when the Resolution Type picklist was left blank. It should have prompted me to select a value from the picklist.
Any help on this would be appreciated!
Thanks
1AND( 2ISPICKVAL( StageName, 'Ti In Progress'), 3RecordTypeId="0122E000000iFFKQA2", 4ISBLANK(TEXT( Resolution_Type__c)) 5)
All Answers
Greetings to you!
Please try the below validation rule:
Or you can use this:
Also, It's advisable to use the RecordType.DeveloperName so you can write the VR like this too:
Please note that DeveloperName is not the same as Name. It is much like API names (can't start with a number, no spaces or punctuation, etc).
So, $RecordType.Name -> Record Type Label
and $RecordType.DeveloperName -> Record Type Name
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Thank you!
https://developer.salesforce.com/forums/ForumsMain#!/feedtype=SINGLE_QUESTION_DETAIL&dc=Formulas_Validation_Rules_Discussion&criteria=OPENQUESTIONS&id=9062I000000IKY2QAO
Already solved, but wanted to add my two cents. I've found that the 15 digit id works in validation rules, just not the standard 18. So I delete the last 3 characters and it works just fine
Sample Validation Rule: each record type must have the correct kind of contract associated with it before it can be won
OR(
RecordTypeId = "0126g000000cnp5" &&
ISPICKVAL(StageName, "Won") &&
ISBLANK(ContractId) ,
RecordTypeId = "0126g000000iREA" &&
ISPICKVAL(StageName, "Won") &&
ISBLANK(ServiceAgreement__c)
)
So my edit would be
AND(
ISPICKVAL(StageName, 'Ti In Progress'),
RecordTypeId="0122E000000iFFK",
ISBLANK(TEXT( Resolution_Type__c))
)