0

I have a requirement to give access to few users changes leads ownership to there names.

So, I need a validation rule if they try to change ownership from other users. But it's not giving any error if they try to change ownership.

AND(
    ISCHANGED( OwnerId ),
    $User.Type__c='Team X', 
    CASE(
        PRIORVALUE(OwnerId),
        "0056F000008CKJ0", 1,
        "00G0k000001WzJJ", 1,
        0) = 1,
    OwnerId <> $User.Id
)

Please let me know where i missed it.

0

3 Answers 3

0

Rather than hardcoding the userIds in validation rule, better to use custom permission set and assign that to desired users who wants to change the lead ownership.

Finally in the validation rule, verify the custom permission set assignment value and logged-in user info with changed owner value.

0

First of all it's not a best practice to use hard coded Id's.

AND(ISCHANGED( OwnerId ),
    $User.Type__c='Team X', 
    OR(PRIORVALUE(OwnerId)="0056F000008CKJ0",
      PRIORVALUE(OwnerId)="00G0k000001WzJJ"
      ),
   OwnerId <> $User.Id)

Alternatively you can create a custom field to update it with

PRIORVALUE([Object].Owner.FirstName ) + " " + PRIORVALUE([Object].Owner.LastName)

and reference it in your validation rule to avoid those hardcoded Id's

​How to get previous "Owner Name" of records on the page by using formula?

0

I tried this formula

AND(ISCHANGED( OwnerId ), 
    CASE( PRIORVALUE(OwnerId), 
    "00590000001Psmg", 1, 
    "00590000001Q4dl", 1, 
    0) = 1, 
    OwnerId <> $User.Id )

And it worked for me.

My test data was- 00590000001Psmg= "test user" 00590000001Q4dl= "test user 12"

logged in user= "test user" created a new lead with owner="test user"

When I try to change the lead owner to "test user 12" then I the VR fires. Please verify if you are following the correct steps to fire the VR.

You must log in to answer this question.

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