I have a custom activity picklist field Act_Type__c. One value of this field is Gift.

My requirement is to create a Task validation rule that will only allow Activity Type to be Gift if the left 3 characters of the WhatId are a12 (Related To must be a custom object record).

I'm new to Salesforce, could you please help with this request.

2 Answers 2


Try with this validtion formula on Task object:

 ISPICKVAL(Act_Type__c, 'Gift'), 
 NOT(BEGINS(WhatId , 'a12'))

This basically translates to: If Act_Type__c is set to Gift AND WhatId doesn't start with a12, throw a validation error.

You can find more information about the above functions by following this link.


you can use BEGINS function in validation Error Condition Formula.

Here is syntax for the BEGINS function:

BEGINS(text, compare_text)

Checks if text begins with specified characters and returns TRUE if it does. Otherwise returns FALSE

You must log in to answer this question.

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