create-actions.js dynamically remove option from dropdown

In sugarCRM 7.2.0 I have a dropdown with legacy items in it. The display values for those items include the text "(legacy)" . I don't want those legacy items to display when creating a new record, they should however display in record view.

In 6.5.15 I would unset those legacy items in the app list strings array during in the pre display on view.edit.php for new records.

In 7.2.0 I am trying to reproduce that functionality in create-actions.js

console.log() is my new best friend and I know I'm getting to the items I want to remove by looping through the app list strings and using javascript match (see hideLegacyValues below).

I just don't know how to unset the options that i want to hide...

It seems that $('[data-name="territory_classification_c"]').options is undefined.
and there are actually no "options" as such in the source code.

Any clues as to the proper way to manipulate dropdown values in code?

Thanks,
FrancescaS

               
   render: function()
   {
      this._super('render');
      this.hideLegacyValues();
   },
                       
   hideLegacyValues: function(){
     // hide legacy items from territory classification
     var territory_list = app.lang.getAppListStrings('territory_classification_list_DD');
     Object.keys(territory_list).forEach(function(key) {
        var check = territory_list[key].match(/legacy/);
        if(territory_list[key].match(/legacy/)){
           //the line below gives an ERROR
           $('[data-name="territory_classification_c"]').options[territory_list[key]].remove();
        }
     });
Parents
  • How crucial is it to have it filtered before it gets to the client? Can you do it on the client side instead and just remove when the document is ready? Could  then remove using something like:
    $("#selectListId option[value='ABC']").remove();

Reply
  • How crucial is it to have it filtered before it gets to the client? Can you do it on the client side instead and just remove when the document is ready? Could  then remove using something like:
    $("#selectListId option[value='ABC']").remove();

Children
No Data