Skip to main content
Nintex Community Menu Bar
Question

Push array of string in picklist

  • July 10, 2024
  • 2 replies
  • 10 views

Forum|alt.badge.img+4
I have written a snippet which is as follows:


     var element = arguments[0],
     $ = skuid.$;
    
    var leadmodel = skuid.model.getModel(“Lead”);
    var raw= leadmodel.getFirstRow();
    var MatterType=raw.Matter_Type__c; // Field on skuid page
    var wlgoffice=raw.WLG_Office__c; // Field on skuid page
    
    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+“'”);  // Query on salesforce object
    


    var opp= result.getArray(“records”); 
     
       
    var string = opp[0].Attornies__c; 
        
           
    var array = string.split(‘,’);  // Create an array of string


//Till Here snippet working fine

    var rowstoupdate ={};
    for(var a=0;a<array.length;a++){
        raw.Attorney__c = array[a];
    }


    leadmodel.updateRows(raw);
    
   
Now i want to assign values of array to Attorney picklist(Attorney__c)  .

How i can achieve this?

Please help as this is urgent.

Thanks in advance 






 

This topic has been closed for replies.

2 replies

Forum|alt.badge.img+7

Gopal,

Do you want to override the values in the Attorney__c picklist on every row, or just the row you’re working with in the snippet? If on every row, you’ll want to use a custom field renderer. Check out this community post to see an example of implementing a custom field renderer. You’ll have to make sure that your picklist options have all the properties that they should, which you can check here at our API reference.


Forum|alt.badge.img+4

Hi Amy,

Thanks for your help.

I have got my issue resolved.

Here is the script , I have used:
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”);
    
    
    if(Att.length!==0)
{
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  });
        }

skuid.ui.fieldRenderers[element.metadata.displaytype]element.mode;
}

Above script is being used to customise value of Salesforce picklist.


And here is second script for field rendering every time field will change


var params = arguments[0];

     var model = params.model;

    var $ = skuid.$;


console.log(‘Snippet Fired!’);


//  Loop through this model’s registered fields

$.each(model.registeredFields,function(){


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

    if ( this.id === ‘Attorney__c’) {        

        console.log(‘Rendering!’);

        this.render();

    }


}); 

Thanks