+ Start a Discussion
raghavi SRraghavi SR 

Fire validation when picklist is selected manually

I have 'lead status' picklist with values.

New
Working
converted
unqulaified

Out of these only unqualified can be selected manually. Others are automatic. When others are selected manually ,a validation must be thrown
I tried using who.name ,it throws error. what can be done?


Thanks in advance.
Nandigam RajeshNandigam Rajesh
Hi raghavi,
FYR
OR( ISPICKVAL(lead status, "new"), ISPICKVAL(lead status, "working"), ISPICKVAL(lead status, "converted") )

Regards
Rajesh​​​​​​​
raghavi SRraghavi SR
Hello Rejesh, 

Thanks for the response .

The Above affects both manual entry and automatic entry like triggers or workflow!

My question is this can happen both manually and automatically. Restriction must be provided when picklist is chosen manually. Any solutions regarding that?

 
Nandigam RajeshNandigam Rajesh
Hi Raghavi,
Better you can choose an trigger with the event before update.

Regards
Rajesh
Malhari KambaleMalhari Kambale
Hi Raghavi,

There are two options I can think of to resolve this:

1. In case of you are using record type for lead, you can select only unqualified  status value for that record type. so that user will have only unqualified to be selected manually, other values will not be shown to the user. Also you can set rest of status values in workflow, trigger and in apex. As we are only showing user unqualified status there is no need of validation.

2. Make New, Working, Converted values as inactive. So that user will not be able to select these values. The limitation for this below:
- You can not use inactive values in list views as well as reports in filters.

Hope this helps.

Regards,
Malhari.
Ajeeth Kumar SAjeeth Kumar S

HI there,

Validation Rule :
AND(!ByPass__C,!ISNEW(),(OR( ISPICKVAL(lead status, "new"), ISPICKVAL(lead status, "working"), ISPICKVAL(lead status, "converted") )))

For Lead Converting :
Please unchecked the Require Validation for Converted Leads  checkbox in Lead Setting.

In trigger : 

Introduce a dummy checkbox field that is not visible to anyone. And let the Validation Rule bypass the record if that checkbox is true. Now, in your trigger before you update oppsToUpdate, first update that dummyCheckbox to true. In this way, the validation rule will be bypassed. Also, make sure you make the checkbox false as soon as the trigger does its action. In order to do this, you can create a workflow or Process Bulider that will do the field update of that dummy checkbox to false whenever the value is true.

Please let me know if you would need any help on this.

Please mark my answer , If it's helpfull for you.


Thanks,
raghavi 

raghavi SRraghavi SR
Hi Ajeeth Kumar,

It looks feasible except for 

For Lead Converting :
Please uncheck the Require Validation for Converted Leads  checkbox in Lead Setting.


we have other validations for lead! 
manali kadammanali kadam
You can use special picklist fields in your formulas, such as IsEscalated for cases and IsWon for opportunities.
Picklist fields can only be used in these functions:
  • ISPICKVAL—Compares the value of a picklist to a single value.
  • CASE—Compares the value of a picklist to multiple values.
  • TEXT—Returns a picklist value’s API Name so that you can work with a reference to the value (even if the displayed value changes) in functions that support text values, such as CONTAINS. (Available in only flow formula resources, formula fields, validation rules, and workflow field updates.)
Ajeeth Kumar SAjeeth Kumar S

Hi ragavi,

Then please use the custom validation(adderror) throught trigger code.

In your trigger before you update oppsToUpdate,set a custom add error with your conditions.

Thanks!..