Need to Remove pickList Value from a perticular picklist Field

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I need to remove a picklist value from a perticular field on a row while they do an edit in table  i.e I don't want to show "Closed Own" Picklist value on stage field . i tried this from what i have learnt.

***********************************************************************************

var field = arguments[0];

value = skuid.utils.decodeHTML(arguments[1]);

oppModel = skuid.model.getModel('OpportunityList');

if (field.mode == 'edit') {

     var picklistEntries = field.metadata.picklistEntries;
   
    console.log(picklistEntries);

    for( var x in picklistEntries){

        console.log(picklistEntries[x].value);

        if(picklistEntries[x].value === 'Closed Own' ){

            console.log(picklistEntries.length);

            picklistEntries.splice(x , 1);

            console.log(picklistEntries.length);

        }

    }

}

skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);


********************************************************************************************

i was able to remove it form picklistEntries , but i am not sure how to update the field with these new List.

Just for Info:
I have a row Action Button with multi action button which updates the Stage to "Closed Own" and at same time Shows a pop-up to enter values in those fields. I don't want users to update stage value to "Closed Own" directly from stage field. 

thanks in advance....
Photo of Chandra Sekhar

Chandra Sekhar

  • 496 Points 250 badge 2x thumb
  • excited to learn something New

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Chandu,

Have you read this? https://community.skuidify.com/skuid/topics/how_do_i_render_custom_picklist_values

Moshe's question and its answer near the bottom of the thread may be helpful.
Photo of Chandra Sekhar

Chandra Sekhar

  • 496 Points 250 badge 2x thumb
Hi Matt,

Thanks for your suggestion , but I have already Checked it..

In the above snippet ,I am able to remove the picklist value from the Picklist field( reflected in the console) , but was not reflecting on the UI.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
If the values are right in the model but not in the UI, you have a rendering problem. Not sure why skuid.ui.fieldRenderers would not be rendering correctly, but you could try forcibly rendering your component to test it:

skuid.component.getComponentById('MyComponentId').render();

NOTE: I haven't examined your code thoroughly. Not sure what's going on there with the while loop and splicing. I'm just trusting that you're correctly removing the entry you don't want.
Photo of Chandra Sekhar

Chandra Sekhar

  • 496 Points 250 badge 2x thumb
Hi Matt,

Apologize for delayed reply

we have ignored the above requirement and for my personal learning, Is there a way to do that , as the above code which i am referring is not working.

thanks in advance..
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Chandu,

I'm sorry, I'm not sure what you're asking.

If you're running Banzai and you want to remove the picklist value for the model, you could try to overwrite the field's metatdata.

If you want to use javascript to remove the value of a picklist, use the code from Moshe here: https://community.skuidify.com/skuid/topics/how_do_i_render_custom_picklist_values