Dynamically adding a text value in picklist field

edited March 3, 2019 in Questions
I want to dynamically add a text value in my existing picklist and save that value so that it is visible fro everyone. Can someone suggest me what should I do?

I have a text field PassingValues and a picklist field Preferresd Category.The user should be able to add a new value in Picklist and the value should be saved and visible to everyone.


  • Matt BrownMatt Brown ✭✭✭✭
    edited March 3, 2019
    Hi Ankita, 

    If you save a value to a picklist field via an action or by overriding the metadata for that field in the model, it will save it back as a new value by default. However, it will be listed as an Inactive Value in the Salesforce field settings. Setting it to active would have to be done via custom code, probably on the backend via Apex, since it's an admin setting and would probably have to run outside permissions. 

    Does that help? Thanks!

  • edited February 25, 2019
    We done dynamic picklists - mostly when we need the picklist values to be based on more then one thing, so a standard Salesforce dependent picklist won't work because it isn't logical enough.

    To do this, we create a snippet called picklistOption and on the field you want to adjust, change the render type to "Custom run a snippet" and select your picklistOption snippet.

    Here is a sample picklist value changer.  This one is based on the user picking a Fruit Type, and the Color picklist (which has the render snippet on it) auto adjusts based on the type of fruit selected.

    This is just an example.  :)  Our real ones have fields pulled off other models to drive logic.

    var $ = skuid.$,
                        field = arguments[0],
                        value = skuid.utils.decodeHTML(arguments[1]);
                    // Run the standard picklist renderer for the given mode
                    if (field.mode == 'edit') {
                        var select = field.element.find('select');
                        if (select.length) {
                            // Remove unwanted entries, we are removing all existing values and recreating them for each row
                                if ($(this).val() !== value  && $(this).val() !== '--None--' && value !== '--None--') {
                              var fruitType = field.model.getFieldValue(field.row,'Type__c',true);
                            // Add new entries
                            if (value !== '--None--' && (value)) {
                                select.append($('<option value="">--None--</option>'));
                                    if (fruitType == 'Apple') {
                                    else if (fruitType == 'Orange') {
                                    else if (fruitType == 'Banana') {
                            else {
                                //add common picklist values here
                                select.append($('<option value="">--None--</option>'));
  • Arne-Per HeurbergArne-Per Heurberg ✭✭✭✭
    edited March 3, 2019
    Hi Matt, are you thinking using MetadataAPI? What would be your suggestion? I have a use case for it. Thanks

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!