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
TraceyTracey 

Testmethods are failing because of Profile Id's in Validation rule

We recently copied across Salesforce production version to our sandbox.

 

I create some Testmethods for a new trigger that I built but now I'm getting an error on some of the validation rules that use the $User.ProfileId in the validation formulae. This makes sense because the Id will change in different orgs.

 

What should I be using then. Should I be using $Profile.Name instead of $User.ProfileId in the validation formulae?

 

Below is a snippet of the error

 

Error Condition Formula: ($User.ProfileId = "00e20000000mxo7" 
|| 
$User.ProfileId = "00e20000000mxoD" 
|| 
$User.ProfileId = "00e20000000mwku" 
|| 
$User.ProfileId = "00e20000000mxsO" ) 
&& 
ISCHANGED(Description) 
&& 
NOT(ISPICKVAL (Status , "New"))
Value(s) Found: Status=New , Description=TestDescription2 , $User.ProfileId=00e20000000hFRI
Result: PASS - Continue
Rule Name: Can_not_Edit_Case_Error_Mess_if_Customer
Error Condition Formula: ($User.ProfileId = "00e20000000mxo7" 
|| 
$User.ProfileId = "00e20000000mxoD" 
|| 
$User.ProfileId = "00e20000000mwku" 
werewolfwerewolf
$Profile.Name would probably be a good thing to try, yes.