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
Kasia Wojewodzka 7Kasia Wojewodzka 7 

Prevent change of record type - Validation Rule Adjustment

Hello 
Hoping that you can help me!
I would like to modify this Validation rule to use for example Case Record Type Name or  Case Record Type Developer Name instead of hardcoded Ids.  

When I tried to replace RecordTypeId = '0123Z000000LKZa' with RecordType.Name I received the error:
PRIORVALUE function cannot reference the RecordType.Name field.

Here is my validation rule: 

AND
(
RecordTypeId = '0123Z000000LKZb',
ISCHANGED(RecordTypeId),
PRIORVALUE(RecordTypeId) = '0123Z000000LKZa',
$Profile.Name <> "System Administrator",
$Profile.Name <> "System Integration",
$Profile.Name <> "CRM Team"

)
AnkaiahAnkaiah (Salesforce Developers) 
Hi Kasia,

You can't use recordtype.Name for ISCHANGED() & PRIORVALUE() functions.

As an alternative, refer below solutions.
https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A8JyMSAV
https://developer.salesforce.com/forums/?id=9062I000000XvPWQA0

If this helps, Please mark it as best answer.

Please let me know if any help required.

Thanks!!

 
Kasia Wojewodzka 7Kasia Wojewodzka 7
I wanted to follow up on the question I posted earlier. 

I found the solution: I created 2 custom Labels and used those in my Validation rule.  

AND
(
RecordTypeId = $Label.CAG_Ref_Lab_Quick_Case_Record_Type,
ISCHANGED(RecordTypeId),
PRIORVALUE(RecordTypeId) = $Label.CAG_Ref_Lab_Case_Record_Type,
$Profile.Name <> "System Administrator",
$Profile.Name <> "System Integration",
$Profile.Name <> "CRM Team"

)