Javascript check if multipicklist value inlcudes value

Is there an easy way to check in the JS API that a multi-picklist field value includes a value?

Something like the below preferably?

    var caseModel = skuid.model.getModel(‘Case’);   
    var caseRow = caseModel.getFirstRow();
    if(caseRow.FieldName.includes(‘My Value’)){
       // Do stuff
    }

Ok, I got bored. This should get you close.

Create a custom field on Contacts like this:

Next, try this page XML. Note you will need to open the JS Console.

<skuidpage unsavedchangeswarning="yes" showsidebar="true" showheader="true" tabtooverride="Contact">   <models>
  <model id="Contact" limit="1" query="true" createrowifnonefound="false" sobject="Contact">
     <fields>
        <field id="FirstName"></field>
        <field id="LastName"></field>
        <field id="CreatedDate"></field>
        <field id="Hobbies __c"></field>
     </fields>
     <conditions>
        <condition type="param" enclosevalueinquotes="true" operator="=" field="Id" value="id"></condition>
     </conditions>
     <actions></actions>
  </model>
{{FirstName}} {{LastName}} {{Model.label}} var $ = skuid.$; var contactModel = skuid.$M('Contact'); var contact = contactModel.getFirstRow(); var hobbies = contact.Hobbies__c.split(';'); console.log('Hobbies: ' + hobbies);

We all like it when Irvin gets bored.  

You going to be at DF15?  Drop by our booths in the Cloud Expo or in the Dev Zone - we’d love to talk. 

Split your field value on ; and then use $.inArray() to check for a particular value, e.g. using Irwin’s Hobbies field example:

var contactModel = skuid.$M(‘Contact’);
var contact = contactModel.getFirstRow();
var isScubaDiver = skuid.$.inArray(“Scuba Diving”,contact.Hobbies__c.split(’;’))>-1;

Exactly what I was needing! Thanks Zach! This is excellent, I can now use this in an IF statement without having to write any extra loops. I owe you a beer.

Now I don’t have to rely on contains like below… :slight_smile:

if(String(extRow.Field_Name__c).indexOf(“myValue”) > -1){
}