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;
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;
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;
}