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
Gabe MarquezGabe Marquez 

Validation Rule Only Works for Sys Admins

I wrote a validation rule on the case object, worked fine for sys admins, but for standard users it always evaluated to true:

NOT(ISPICKVAL(Status,'Closed')) &&
IF( AssetId <> NULL, Asset.AccountId <> AccountId, false)

I wrote 2 others, that didn't ever evaluate to true:


NOT(ISPICKVAL(Status,'Closed')) &&
IF( NOT(ISBLANK( AssetId )) ,
Asset.Account.Name = Account.Name,false)


NOT(ISPICKVAL(Status,'Closed')) &&
IF(AssetId <> NULL,
If( AccountId <> NULL,
Asset.Account.Name <> Account.Name,false), false)


What don't any of these work? What should the rule say??
Best Answer chosen by Gabe Marquez
AgiAgi
Hi,

as the validation rule fires when the formula is true, you may use And instead of If function,
ex.

AND(
NOT(ISPICKVAL(Status,'Closed')),
AssetId <> NULL,
Asset.AccountId <> AccountId)


AND(
NOT(ISPICKVAL(Status,'Closed')),
NOT(ISBLANK( AssetId )) ,
Asset.Account.Name = Account.Name)


AND
NOT(ISPICKVAL(Status,'Closed')),
AssetId <> NULL,
AccountId <> NULL,
Asset.Account.Name <> Account.Name)

All Answers

kevin Carotherskevin Carothers
is the account record locked?
Gabe MarquezGabe Marquez
I'm not sure what you mean. The org wide defaults for all objects are set to read/write. Thank You, Gabe Marquez (707) 592-3639 [image: Kyazma Business Consulting] [image: cert small]
AgiAgi
Hi,

as the validation rule fires when the formula is true, you may use And instead of If function,
ex.

AND(
NOT(ISPICKVAL(Status,'Closed')),
AssetId <> NULL,
Asset.AccountId <> AccountId)


AND(
NOT(ISPICKVAL(Status,'Closed')),
NOT(ISBLANK( AssetId )) ,
Asset.Account.Name = Account.Name)


AND
NOT(ISPICKVAL(Status,'Closed')),
AssetId <> NULL,
AccountId <> NULL,
Asset.Account.Name <> Account.Name)
This was selected as the best answer
Gabe MarquezGabe Marquez
I used:

AND(
NOT(ISPICKVAL(Status,'Closed')),
NOT(ISBLANK( AssetId )) ,
Asset.Account.Name  <>  Account.Name)

Perfect! Thank you.