How to empty dropdown option and add new option

Hi Community,

I have a drodown my name location.

How to empty location dropdown option and add new option with Option value as 'AC' and text as 'Please Select Location' while creation of Accounts.

Thanks in advance

Regards

Sam Roy Ramana Raju Santhana

Parents
  • Hi Sam Roy

    If you want to remove options from dropdown and add new option throug code while creation of Account to do so:

    In custom/modules/Accounts/clients/base/views/create-actions/create-actions.js file

    ({ 
    extendsFrom: 'CreateActionsView',
    initialize: function (options) {
       console.log('initalized CreateActionView');
       this._super('initialize', [options]);
       this.emptyDropdownValues();
    },
    emptyDropdownValues: function(){
       var territory_list = app.lang.getAppListStrings('location_list');
       Object.keys(territory_list).forEach(function(key) {
          delete territory_list[key];
       });
       territory_list['AC'] = "Please Select Location";
       this.model.fields['location'].options = territory_list;
    },
    _dispose: function() {
       this._super('_dispose');
    }
    })

    Hope this Helps..!!

    Best Regards

    S Ramana Raju

  • Hi Ramana Raju Santhana,

    when I apply this code I got an error 

    Uncaught TypeError: Cannot set properties of undefined (setting 'options')

    please help me to sort it out.

Reply Children
No Data