0

Hope you are all fine,

I'm doing a validation rule over a multi-select picklist that should avoid to be changed on certain substatus. Validation rule is a as follows:

AND(
    $Profile.Name <> "System Administrator",
    ISCHANGED(substatusRoofer__c),
    OR(
        CONTAINS( PRIORVALUE ( substatusRoofer__c), "Alta de candidato roofer"),
        CONTAINS( PRIORVALUE ( substatusRoofer__c), "1")
    )        
)

Here i used both API Name and label, just in case, but the weird part is in log:

Profile.Name=Administrador del sistema , substatusRoofer__c=0AAB0AAC VALIDATION_PASS

I thought it could be hexadecimal, but is not, looks more like the order Salesforce establish over positions in the multi-select picklist, so in this case:

  • 0AAA would be non selected
  • 0AAB would be first value selected
  • OAAB0AAC would be first and second values selected

I don't know if anyone could give me the right approach on how to do a validation rule that actually works, or understand why is Salesforce checking over the position in the picklist of the values selected.

Thanks!

1 Answer 1

0

The right formula is as follows:

AND(
    $User.ProfileId <> 'xxxxx',
    ISCHANGED(substatusRoofer__c),
    OR(
        INCLUDES( PRIORVALUE ( substatusRoofer__c), "1"),
        INCLUDES( PRIORVALUE ( substatusRoofer__c), "12")
    )        
)

So the changes had been, user.profileId instead of profilename because it was checking me as "Administrador del sistema" instead of "System Administrator" and INCLUDES vs CONTAINS.

1
  • Have you tested this formula without the user profile condition?
    – arut
    Commented Apr 8, 2020 at 12:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .