0

I am trying to create a validation rule to fire if owner of a record is active then its owner cannot be changed. But doesn't seem to work?

AND(      
  Owner:User.IsActive = true,    
  ISCHANGED(OwnerId)
)
1
  • Please edit your question to add the important information that you included in comments on @SaiPraveenKakkirala 's answer.
    – Moonpie
    Apr 4, 2022 at 16:13

2 Answers 2

2

Basically it doesn't work because your Validation Rule will be triggered when: The owner changed and the new owner is active

What you would like to achieve would be:

AND(
  PRIORVALUE(Owner:User.IsActive) = true,    
  ISCHANGED(OwnerId)
)

Unfortunately you cannot use PRIORVALUE with such parameter. There is a workaround for this, you simply have to create a formula field OwnerIsActive__c with formula Owner:User.IsActive and then use it in your Validation Rule like that:

AND(
  PRIORVALUE(OwnerIsActive__c) = true,    
  ISCHANGED(OwnerId)
)

P.S : Using Owner:User.IsActive is valid for all objects that accept queue as owner, otherwise use Owner.IsActive.

1
  • Correct. This is the way to go as also was suggested by Sai. Thanks for the details Bartheleway.
    – Col
    Apr 5, 2022 at 5:03
-1

You had a small error in the validation rule.Can you use the below validation rule

AND( ischanged(OwnerId),Owner.IsActive = true )

And on lead object the below validation rule is working as expected.

We cannot add PRIORVALUE to the related object field like to the User object active field. You may have to use the trigger logic to fire the validation or create a formula field to get the active field on user to lead and use the PRIORVALUE on that field

8
  • Error: Specify an object type for the Owner field.
    – Col
    Apr 4, 2022 at 7:54
  • Can i know on which object you are trying this rule. I tried on Opportunity and it worked with out any error . Apr 4, 2022 at 7:55
  • Validation rule is on Lead object.
    – Col
    Apr 4, 2022 at 7:58
  • If that is on lead object The below validation rule is working as expected. AND( ischanged(OwnerId),Owner:User.IsActive=true). I tried to update the owner of the lead and the present owner is already active and validation rule got fired Apr 4, 2022 at 8:02
  • Yes, its firing but the problem is its also firing when the leads record owner is inactive as well. So its firing for both conditions, when the record owner is active and also when its inactive. It should not fire when the record owner is inactive.
    – Col
    Apr 4, 2022 at 8:09

You must log in to answer this question.

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