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
CodeRedKyleCodeRedKyle 

Task Validation Rule

I want an error message when someone attempts to assign a task of a certain type if they don't assign it to the correct person.  

 

Here is what I have:

 

(OwnerId <> "Kyle Hill") && (ISPICKVAL (CallType, "PROGRAM MANAGEMENT - NEW ENROLLMENT"))

 

I get no errors when saving this rule, but also no errors no matter who I assign to the task.  

 

Any ideas? (i'm very new at this) 

 

Thanks in advance! 

 

Best Answer chosen by Admin (Salesforce Developers) 
JimRaeJimRae

I got it figured out a different way, you could try.

 

Use this code instead:

 

 

And( ( OwnerId <>"005000000018b2a"), ( ISPICKVAL( CallType, "PROGRAM MANAGEMENT - NEW ENROLLMENT")))

 

 This will only error if both of these are true.

 

All Answers

CodeRedKyleCodeRedKyle
I'm not sure why there are winking faces
JimRaeJimRae

Your ownerid is going to be a userid value, not the name.  Something like "00500000001Bc2e".

 

You are getting the smilies because you typed code, and didn't use the "insert code" button (the clipboard with the c on it).  Any time you have semicolon and paranthesis ;   )  next to each other ;) you will get the smilies.

 

 

 

CodeRedKyleCodeRedKyle
Thanks!  - Where do I find my user ID?
JimRaeJimRae

If you go to manage users in setup, select "users" , then find the user you need the ID for.

 

select their full name, then look at the URL your browser is set to

 

it will be something like https://cs3.salesforce.com/00570000003IqBj 

 

The string that starts with the 005  and is 15 digits long is the user id.

CodeRedKyleCodeRedKyle

Thanks, I did that - but no change.  Should I have the userid in ""?  or not

 

if you could correct my (OwnerId <> "005XXXXXXXXXXXX") && (ISPICKVAL (CallType, "PROGRAM MANAGEMENT - NEW ENROLLMENT")) 

 

can you correct what i have?

 

JimRaeJimRae
That should work, when you validate it, do you get "no Syntax errors"?  How do you know it is not working correctly?
JimRaeJimRae
One more thing, did you remember to activate it?  You have to select the active checkbox in order for it to work.
CodeRedKyleCodeRedKyle

It's active, and no syntax errors - when I go and make a new task, the error doesn't show - it just saves

 

 

CodeRedKyleCodeRedKyle

actually - now that I changed to the user ID it shows syntax error ")" missing

 

JimRaeJimRae

I got it figured out a different way, you could try.

 

Use this code instead:

 

 

And( ( OwnerId <>"005000000018b2a"), ( ISPICKVAL( CallType, "PROGRAM MANAGEMENT - NEW ENROLLMENT")))

 

 This will only error if both of these are true.

 

This was selected as the best answer
CodeRedKyleCodeRedKyle

I really appreciate your help - for some reason I'm still not getting the result I'm looking for.  No matter who I put as the owner of the task, no errors show up.

 

JimRaeJimRae
Open the system log before you save the task, and post the log so we can look at it.
CodeRedKyleCodeRedKyle

How would I do that?

 

JimRaeJimRae

I am assuming you have system administrator access to the system.  on any screen, near the top, you should have several links; including setup and logout  in between these should be a link called "System Log"  click that link to open the log window.

I would recommend, once you find that link, you do the following:

navigate to the new task, set it up and get ready to save, then open the log window (this will limit what is in the log to relevant information), then save.

You can then copy and paste the log window results to your reply.

 

This is what it looks like on my instance:

 

5:15:01 DEBUG - *** Beginning Task Validation Rule Evaluation for null Start Time: 20090819191501.066 Rule Name: checkval Error Condition Formula: And( ( OwnerId <>"005000000021k2a"), ( ISPICKVAL( CallType ,"Email"))) Value(s) Found: OwnerId=005000000021k2a , Type=null Result: PASS - Continue End Time: 20090819191501.066 *** Ending Task Validation Rule Evaluation for null

 

 

 

CodeRedKyleCodeRedKyle

Jim - Thanks so much - by looking at the system log I found that I was looking at the wrong field, instead of call type, it just needed to be "type"

 

Thanks so much for your help - You've taught me a lot today! 

JimRaeJimRae
Glad to help!
Sai kalyanSai kalyan

Could you please tell about the Task validation