Custom Picklist rendering (Salesforce)


Render picklist values on basis of two other picklists.

for Example Picklist A, Picklist B, Picklist C

Render Picklist C values every time values of Picklist A and Picklist B will be changed.

Script 1: (Which user have to put on the field(Picklist C) on which user want to show custom picklist values).

var element = arguments[0],value = skuid.utils.decodeHTML(arguments[1]),$ = skuid.$;

//Get Lead model information
    var leadmodel = skuid.model.getModel(“Lead”);
    //Fetch first row of Lead info.
    var raw= leadmodel.getFirstRow();
    // Get Matter type field value
    var MatterType=raw.Matter_Type__c;
    // Get WLG office field value
    var wlgoffice=raw.WLG_Office__c;
    // Perform query on salesforce object on basis of Matter type and WLG office on Lead
    var result = sforce.connection.query(“SELECT Name,Attorney__c,Matter_Type__c,Wlg_Office__c,Attornies__c,Id FROM Consulting_Attorney__c where Matter_Type__c =’”+MatterType+"‘AND Wlg_Office__c =’"+wlgoffice+"’"); 
    var Att = result.getArray(“records”);
var array = Att[0].Attornies__c.split(’,’);
var records = array.toString().replace(/,/g , “’,’”); 

// Fetch Salesforce users informations
var result1 = sforce.connection.query(“SELECT name FROM user WHERE Id in (’”+records+"’)");  
var Users = result1.getArray(“records”);
   // Create a array for Custom Picklist
var picklistEntries = [];

picklistEntries = element.metadata.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;     

        for(var a=0;a<Users.length;a++){
            picklistEntries.push( { value:Users[a].Name , label:Users[a].Name, defaultValue: false, active: true  });


Script 2: This script will be put on model action. 

var params = arguments[0];

     var model = params.model;

    var $ = skuid.$;

console.log(‘Snippet Fired!’);

//  Loop through this model’s registered fields


    //  If this is the row that was updated, loop through the fields to find the one we want

    if ( === ‘Attorney__c’) {