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

    Your code is clean and consistent. I'm just curious why you choose to add the _dispose function? Is it just habit? Surely since you are extending the class, there's no need to call it explicitly? Or is there an advantage I'm not aware of?

Reply Children
No Data