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
TWCSYSADMIN09TWCSYSADMIN09 

Formula field with multiple conditions using picklist...

Hello Everyone!,

 

I need to create a formula field that will update a field with text based on certain criteria.

 

Ex:  If division_c = yes and BCP = yes, update the formula field with AAABBBCCC.  I have tried multiple varitions of the ISPICKVAL () using AND, IF and nothing seems to work.

 

Any help is greatly appreciated!  

Best Answer chosen by Admin (Salesforce Developers) 
MarkSilberMarkSilber

I'm assuming the field you want to update is text, correct? If it's a picklist, you can only pre-select a value which means you would need multiple workflow rules.

 

To set a value in a text field, you just need to have the result be the value. For example. Assuming the 2 fields you are checking are picklists:

 

 

IF(AND(ISPICKVAL(Division__c, "Yes"), ISPICKVAL(BCP__c, "Yes")),"AAABBBCCC", "")

 

The formula will result in "AAABBBCCC" if both Division and BCP are Yes, otherwise it will return a null. If you want to leave the original value in the field, just replace the last part with the name of the field you are updating. This should give you a good start. If you are still having trouble, please post the actual field names and types and I can help construct the actual formula. 

All Answers

MarkSilberMarkSilber

I'm assuming the field you want to update is text, correct? If it's a picklist, you can only pre-select a value which means you would need multiple workflow rules.

 

To set a value in a text field, you just need to have the result be the value. For example. Assuming the 2 fields you are checking are picklists:

 

 

IF(AND(ISPICKVAL(Division__c, "Yes"), ISPICKVAL(BCP__c, "Yes")),"AAABBBCCC", "")

 

The formula will result in "AAABBBCCC" if both Division and BCP are Yes, otherwise it will return a null. If you want to leave the original value in the field, just replace the last part with the name of the field you are updating. This should give you a good start. If you are still having trouble, please post the actual field names and types and I can help construct the actual formula. 

This was selected as the best answer
TWCSYSADMIN09TWCSYSADMIN09

Thanks for you formula, but unfortunately, I am still receiving an error message:  Error: Incorrect parameter for function ISPICKVAL(). Expected Picklist, received Text

 

This is formula I used:    IF(AND(ISPICKVAL( Division__c , "Yes"), ISPICKVAL( Sell_any_BCP_or_PRI_lines__c , "Yes")),"AAABBBCCC", "")

 

I would like the field to be a text field, only if both conditions are met.

 

 

TWCSYSADMIN09TWCSYSADMIN09
This works!  Thank you so much!!!
MarkSilberMarkSilber
Glad you got it working. I was going to ask if both the fields you were checking against are picklists, which I'm guessing they weren't, which is why you were receiving the error, correct?
TWCSYSADMIN09TWCSYSADMIN09

Actually, the Division field was a formula field that was being pulled from the Account object, which was picklist field.  So I created a picklist field on the Contract object (did not put it on page layout) and it worked like a charm!

 

Thanks again for your help!

MarkSilberMarkSilber

If this field is on the Contract object, you have access to the Account fields directly in a formula without having to create a new field. You can reference the Account's Division field by using Account.Division__c in your formula.

 

 

IF(AND(ISPICKVAL(Account.Division__c, "Yes") ......

 

 

 

TWCSYSADMIN09TWCSYSADMIN09

Perfect!  Thanks!  I was sure if I could reference different object in a formula field.

 

MarkSilberMarkSilber
When you have a chance, can you change your "Accepted Solution" to the reply that has the example formula? This will make it easier for other users to see the reply that solved your problem.

Thanks.
fifedogfifedog
Mark, I've marked the solution which I think has the correct solution, please confirm.  Also it's great to see you active on the boards!