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
sfnsfn 

trouble setting up opportunity validation rule

I'm trying to set up an Opportunity validation rule, whereby if "Closed Lost" is selected from the Stage picklist, a specified custom field (Reason) must be completed. 

I set up the formula as follows:

 

AND (

ISPICKVAL(StageName,"Closed Lost"),

ISNULL(Reason__c))

 

No errors are found, but I do not get an error message when selecting this criteria.

 

Also, can validation rules be specific to certain record types only?

 

Thanks for your help!

Best Answer chosen by Admin (Salesforce Developers) 
MarkSilberMarkSilber

Validation rules are at the field / record level and are not page layout specific. Your alternative is add some additional criteria to the validation rule to look at the current user's profile and only require it if their profile is one of the Sales profiles.

 

 

AND(ISPICKVAL(StageName,"Closed Lost"), LEN(Reason__c)=0, AND( $Profile.Name = "Your Sales Profile Name", $Profile.Name = "Your Other Sales Profile Name"))

 

 

 

All Answers

jisaacjisaac

We have picklists as our Reason Lost and have that field as a Dependent Drop-down based on the Stage. But if you want to leave the Reason Lost as a free-form text field, that won't work obviously.

 

It is an option to consider and makes reporting easier to see how many deals we lost due to Price, or Function, or Delivery Date, etc. Text fields are fine for capturing the story but not feasible for reporting metrics back to Mgmt.We also have a  free-form field where they can put their story and many of them do so that the information is captured somewhere and they don't have to field calls saying - "what happened????"

MarkSilberMarkSilber

You can't use the ISNULL function to check for null in text fields. You have to use the LEN function instead.

 

 

AND(ISPICKVAL(StageName,"Closed Lost"), LEN(Reason__c)=0)

 

As a side note, I completely agree with jisaac - you should capture the reason in a picklist, not a text field to make reporting and future analysis easier. 
Message Edited by Mark Silber on 08-08-2009 04:43 AM
sfnsfn

hmmm, still doesn't seem to work.

 

a separate picklist exists for set closed lost reasons (for reporting purposes), but management wants additional commentary from the sales team (required).  this free text field is what i'm trying to make required by creating a validation rule.

 

does anyone know if validation rules can be specific to each page layout when the fields are shared?

 

thanks

MarkSilberMarkSilber

Validation rules are at the field / record level and are not page layout specific. Your alternative is add some additional criteria to the validation rule to look at the current user's profile and only require it if their profile is one of the Sales profiles.

 

 

AND(ISPICKVAL(StageName,"Closed Lost"), LEN(Reason__c)=0, AND( $Profile.Name = "Your Sales Profile Name", $Profile.Name = "Your Other Sales Profile Name"))

 

 

 

This was selected as the best answer
sfnsfn
Thanks so much for your help, Mark.  That did the trick!