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
Robert WynterRobert Wynter 

adding a multi-picklist field into my formula for my custom button

I have a custom button that has a javascript picklist that checks feild criteria. I need to add a multi-picklist field to the if statement to check if it does NOT contain "India".
 
if('{!Account.Original_Contract_Start__c}' == '' || '{!Account.Current_Contract_Start__c}' == '' || '{!Account.Contract_End__c}' == '' || '{!Account.Status__c}' != 'Active' || {!INCLUDES(!Account.Target_Market__c, "India") == False } ) {



and here's the full syntax if needed:
 
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")} if('{!Account.Original_Contract_Start__c}' == '' || '{!Account.Current_Contract_Start__c}' == '' || '{!Account.Contract_End__c}' == '' || '{!Account.Status__c}' != 'Active' || {!CONTAINS(!Account.Target_Market__c, "India") == False } ) { window.alert("Hello {!$User.FirstName} Please make sure you have entered the values in Contract End, Original Contract Start and Current Contract Start fields and that the Account Status is Active"); } else if('{!Account.Status__c}' == 'Active' && '{!Account.Approval_Progress__c}' == 'Closed Won') { window.open("/apex/echosign_dev1__AgreementTemplateProcess?masterid={!Account.Id}&templateId=a08o000000C6jYl ","_blank"); } else if('{!Account.Status__c}' == 'Active' && '{!Account.Approval_Progress__c}' == 'Approved') { window.open("/apex/echosign_dev1__AgreementTemplateProcess?masterid={!Account.Id}&templateId=a08o0000004m8XH ","_blank"); }
Parker EdelmannParker Edelmann
Try changing {!INCLUDES(!Account.Target_Market__c, "India") == False } to {!NOT(INCLUDES({!Account.Target_Market__c}, "India"))} Although as it is in a set of OR statements, if any of the other statements are true, then it will execute the then. Did you want them to be ANDs instead of OR's?. It seems that the two statements are equivalent, so I'm not sure what is happening. Let me know if it works or more thinking is necessary.

Thanks,
Parker
Robert WynterRobert Wynter
Yup tried that one too with now luck. Error: Field Account.Target_Market__c is a multi-select picklist field. Multi-select picklist fields are only supported in certain functions.

Thx for trying though
Robert WynterRobert Wynter
got it working with :
'{NOT(!INCLUDES(Account.Target_Market__c, "India"))}'
removed the ! from (Account.Target_Market__c
Parker EdelmannParker Edelmann
Awesome. I assume you've tested it that it gives the correct results. If you haven't, you may want to, because the syntax still looks a little funny to me, but I'm not a develper, so I could be wrong. I just like playing with formulas.

Thanks for posting your question,
Parker
Robert WynterRobert Wynter
I did a rookie move. I tested that when the conditions are not met but didn't test if it works when conitions are met, which is giving me the same result :(. but I'm closer than I was yesterday. So my popup msg comes up whether it's met or not.
Parker EdelmannParker Edelmann
First of all, remove my answer as being best until the issue is truly solved. Secondly, what are the complete conditions and the types of the fields involved in those conditions? You may need to remove the quotes from the variables you are are trying to evaluate, as they already return a specific type. Keep in mind I've only dabbled in code, so I don't know exactly when to wrap things in quotes, declare a variable, etc. However I will be of service to build the necessary conditional, but maybe not turn it into code. Also, if I understand right, the current conditional is always evaluating to true and giving the window.alert, correct? Basically a simple restructuring of the if parameter is necessary to fix this.

Thanks,
Parker
Robert WynterRobert Wynter
The 2 date fields are Date Types, the Status field is text and the new field in the criteria Target_Marget__c is a Multi-Select Picklist. Date fields == blank Status != "Active" and target Market does not contain "India" this condition should evaluate to true thereform window alert
Parker EdelmannParker Edelmann
Try using && where you used ||. && = AND()   || = OR()
In other words try something like this (I added a few additional tweaks):
if({!ISBLANK(Account.Original_Contract_Start__c)}  && 
ISBLANK(Account.Current_Contract_Start__c)} && 
{!ISBLANK(Account.Contract_End__c)} && 
{!Account.Status__c != 'Active'} &&
{! NOT(INCLUDES(Account.Target_Market__c, "India")) } 
   )
Try something similar to that. I doubt that's the 100% perfect syntax, so it'll need some tweaking. Let me know of the results.

Thanks,
Parker
Robert WynterRobert Wynter
Still couldn't get it work work. I tried a work around that is working. I created a hidden formula field that eqauls the values selected on the picklist. Then I used the formula text field in my criteria. It's a roundabout way of doing it. I really wish I could figure out the proper syntax with picklist. I'm sure I'll come across this issue again. thx for you help Parker
Parker EdelmannParker Edelmann
Here's a link that may help you: https://help.salesforce.com/apex/HTViewHelpDoc?id=tips_for_using_picklist_formula_fields.htm
If you want, you can mark your previous answer as best, or whatever suits you best. Translating formulas to non-visualforce script is a challenge for me as I'm just starting with apex code and code in general, so I won't be able to help you there. I'm glad I could help as far as the formula is concerned, but I wish I knew more so I could help you and others better and also for when I want to write my own code. (It's a real pain to know exactly what you want to do, but can't write the script for it.)

Thanks again,
Parker