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
Georgia2Georgia2 

Making a lookup field required based on a pick list

Hi

I have two look up fields on an Oppty- a look up to an Account (Ship to Account) and a look up to a custom object (Shipping Address).

I have a pick list for type of Shipping Info: Ship to Account or Shipping Address.

I need a validation rule that so if Shipping Info is a Ship to Account than Ship to Account field is required otherwise Shipping address is required.

 

Thoughts?

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
Steve :-/Steve :-/

Here you go, Happy Thanksgiving ;-)

 

 

OR(AND(ISPICKVAL(Picklist_Field, "Option-1"), LEN( Lookup_Field_1 ) < 1), AND(ISPICKVAL(Picklist_Field, "Option-2"), LEN( Lookup_Field_2 ) < 1))

 

 

 

 

 

All Answers

Steve :-/Steve :-/
I think you just need to use a couple of ISPICKVAL's for your Picklist options and LEN <1 for your LookUp Fields.
Georgia2Georgia2
Do you have an example?  Thanks
Steve :-/Steve :-/

Here you go, Happy Thanksgiving ;-)

 

 

OR(AND(ISPICKVAL(Picklist_Field, "Option-1"), LEN( Lookup_Field_1 ) < 1), AND(ISPICKVAL(Picklist_Field, "Option-2"), LEN( Lookup_Field_2 ) < 1))

 

 

 

 

 

This was selected as the best answer
Georgia2Georgia2

Very good- thanks!  How do I mark as solved?  For some reason I can never find this.

Thanks

Steve :-/Steve :-/
in the upper righthand corner of each post there should be a green box with a white checkmark in it. 
Georgia2Georgia2

I had to change my encoding to Right-to-Left Document to see this.  any idea how I can get my computer screen to show everything?  Often times, the solutions are cut off on the right hand side; probably due to the same thing...

Thanks

SalesScaleSalesScale

Am having trouble hijacking your syntax, seems like it should be simple:

 

 

AND(ISPICKVAL( StageName , "Closed Won"), LEN(  Won_Reasons__c  ) < 1) 

 

 

Error: Field Won_Reasons__c is a picklist field. Picklist fields are only supported in certain functions. Tell me more

 

Thanks for any help on this.

 

 

Steve :-/Steve :-/

As the error message states, your custom field Won Reasons is a Picklist, you cannot use a LEN function on a Picklist field.

 

Try something like

 

AND(ISPICKVAL( StageName , "Closed Won"),ISPICKVAL( Won_Reasons__c , ""))

 

 Or better yet, since your requirement is Closed/Won you don't even need to evaluate the Stage Name picklist, you can just evaluate the IsWon field

 

AND( ( IsWon ), ISPICKVAL( Won_Reasons__c , ""))

 

PS.  You should use the Code Clipboard when you post formulas, it makes them a lot easier to read/ 

 

 

SalesScaleSalesScale
Perfect, thanks!