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)
)
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)
)
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
.
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
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
Commented
Apr 4, 2022 at 8:02