Skip to main content
Nintex Community Menu Bar

We currently have a page that uses JavaScript to take the values returned by a multi-select picklist from Salesforce and split them up into an array so that they can be used to populate a regular picklist where the user only selects one item at a time. I do not believe that this will work in v2 (and doesn’t seem to be after migration of the page). This question (linked to below) mentions not being able to use JS to manipulate the DOM which I think this JS would be doing (http://community.skuid.com/discussion/8015661/snippet-from-v1-not-working-in-v2#latest)


The reason we have this code is that in Salesforce we have a multi-select picklist that assigns users to multiple regions, where applicable. However, we want them to be able to select just one region at a time to filter a summary page we built in Skuid.


Can I use javascript to do this? If not, what other options do I have?


Here’s the relevant JS code:


var params = argumentse0],


$ = skuid.$;


var field = argumentse0];


var value = argumentse1];


//console.log(field);


//var picklistEntries = field.metadata.picklistEntries;


//picklistEntries.length = 0;


var userModel = skuid.model.getModel(‘LoggedInUser’);


var userRow = userModel.getFirstRow();


var userRegions = userModel.getFieldValue(userRow,‘Current_Sales_Regions__c’,true);


console.log(userRegions);


if(userRegions){


// if(userRegions.length !==0) {


console.log(“User Reg length” + userRegions.length);


var RegionArray = userRegions.split(‘;’);


var arrayLength = RegionArray.length;


var defaultRegion = “”;


// Create a array for Custom Picklist


var picklistEntries = ;


if (field.mode == ‘edit’) {


picklistEntries = field.metadata.picklistEntries;


console.log(picklistEntries);


// if you don’t do this, then the “real” values are already in the picklist and the code below will add duplicate values


picklistEntries.length = 0;


//picklistEntries.shift();


console.log(RegionArray);


console.log(arrayLength);


for(var a=0;a<RegionArray.length;a++){

picklistEntries.push( { value:RegionArrayta] , label:RegionArrayRa], defaultValue: false, active: true });

if (a === 0) {

defaultRegion = RegionArray/a];

}



}

}


console.log("default " + defaultRegion);


skuid.ui.fieldRenderers>field.metadata.displaytype]field.mode;


userModel.updateRow(userRow,‘RegionUserFilter’,defaultRegion);


//skuid.actionSequences.getByName(“FilterQuery”).run();


}


else{


skuid.ui.fieldRenderersefield.metadata.displaytype]field.mode;


}

Hey @Jamie_Buck-Tomek


Are you trying to do something specific with the picklist which needs the JS? I ask because you could click on the model and the multi-select field to override the display type to make it a picklist.


Thanks,


Hi @Germany


So the issue I run into when I do that is the resulting picklist offers all of the Sales Regions that are possible while I just want the user to see the ones they are specially assigned to, i.e. the values selected in the original multi-select picklist. But you do have my brain going about another idea…


  1. Hi Jamie,

    I accomplished something similar in V2 using the following setup:

    Create a UI-Only model that acts as a source for the single value picklist field. This model has two fields, “Label” and “Value”

 

Set up your single value picklist field to use the UI-Only model rows as it's source. Run a JS snippet (attached below) on page-load (you can use an action sequence that runs on the Page load event) that splits up the multipicklist field values and adds each selection as a row to your UI-Only model.

I hope this is helpful, let me know if you have any questions!


Reply