clear old values of picklist every time it will render

  • 1
  • Question
  • Updated 3 years ago
  • Answered

I have implemented custom rendering functionality on a custom picklist.

Please find attached screen shot.


There are three picklists A, B, C.

Whenever values of A & B will be changed, different values of C will be displayed.

Issue: Suppose user will select values in picklist A and B, and on basis of that user select value on picklist C.

But before saving user want to change value of Picklist B , thus picklist C values should be rendered again and should display different values.

But it is showing previous selected value and new rendered values.

Means picklistentries is not being refreshed properly.

I have attached few screen shot regarding this issue, Please help as it is urgent.

Attached is snippet

Through this snippet , i am getting values in picklist entries

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;
    var Attorney=raw.Attorney__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");
    if(Att.length!==0 && Att[0].Attornies__c!==null)
   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  });


Through below snippet i am rendering PIcklist C every time Picklist A and B will change (Through Model action)

var params = arguments[0];

     var model = params.model;

    var $ = skuid.$;

//  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') {        




Thanks in advance
Photo of Gopal Agrawal

Gopal Agrawal

  • 598 Points 500 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

  • 13,702 Points 10k badge 2x thumb

Try adding a Model Action that runs your snippet every time field A or B is changed.


Photo of Gopal Agrawal

Gopal Agrawal

  • 598 Points 500 badge 2x thumb
Thanks, Bill.

I have created a model action which is updating Picklsit C value by --None-- and behind the scene(in Salesforce)

I have made that picklist required.

Thank you again.