+ Start a Discussion
JakesterJakester 

Help with account owner validation rule

Hello,

 

I'm trying to make it so that the Accounts with a type of Customer can only be owned by someone in the Sales profile. I don't see a way to restrict by profile, so the closest I've come is to call out user ids, with the following validation rule:

 

 

and(case(OwnerId, "005500000011YxTAAU",false, "005500000011YxbAAE",false, "005500000011YB4AAM",false, "005500000011YxRAAU",false, "005500000011YxhAAE",false, "005500000012etTAAQ",false, "005500000011YAkAAM",false, true) , ispickval(Type,"Customer") )

 This fails with "Error: Incorrect argument type for function case()." Help - what am I doing wrong?

 

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
rpr2rpr2

Here is what I think will work.  No syntax errors, but untested.

 

OwnerId<>"005500000011YxTAAU" && OwnerId<>"005500000011YxbAAE" && OwnerId<>"005500000011YB4AAM" && OwnerId<>"005500000011YxRAAU" && OwnerId<>"005500000011YxhAAE" && OwnerId<>"005500000012etTAAQ" && OwnerId<>"005500000011YAkAAM" && ispickval(Type,"Customer")

 

All Answers

SteveMo__cSteveMo__c

What about using the User's Profile.Name? 

 

I wrote this to give certain user Profiles and Opportunity Types an exemption from a requirement that New Opportunities must start below 50% Probability.

 

 

AND (ISNEW(), Probability >= 0.50, NOT( $Profile.Name = "System Administrator"), NOT( $Profile.Name = "CSDS Executive Support"), NOT( $Profile.Name = "Executive Support"), NOT( $RecordType.Name = "Bundle Sales Opportunity") )

 

 You might be able to Reverse Enginieer it to lock down Custom Accounts to except Sales Users

 

JakesterJakester
The problem isn't with not letting a particular user change the record - the problem is with letting the Owner be somebody not in Sales.
Message Edited by Jakester on 06-19-2009 07:56 PM
SteveMo__cSteveMo__c

Ugh!  you're right...  and it looks there's no handle to the $Owner.Profile (like there is with $User)

 

 

JakesterJakester
Yeah, and I can't even get it to work when I call out specific userIDs, either - any ideas anyone?
rpr2rpr2
I was able to create a rule testing for myself as being the only valid owner and it worked - using this syntax: 

OwnerId<>"005700000011kmP"

 

You should be able to add onto this to accommodate multiple IDs.
rpr2rpr2

Here is what I think will work.  No syntax errors, but untested.

 

OwnerId<>"005500000011YxTAAU" && OwnerId<>"005500000011YxbAAE" && OwnerId<>"005500000011YB4AAM" && OwnerId<>"005500000011YxRAAU" && OwnerId<>"005500000011YxhAAE" && OwnerId<>"005500000012etTAAQ" && OwnerId<>"005500000011YAkAAM" && ispickval(Type,"Customer")

 

This was selected as the best answer
JakesterJakester

You rock!! Thanks so much!