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

    why you have used 

    _dispose: function() { 
       this._super('_dispose');
    }

    what is the need of this...

  • Hi Bhavin Patel Alan Apter

    -> The controller calls the dispose method on its models/collections and then removes its references to them.
    -> On disposal, each model clears all of its attributes and disposes all associated views.
    -> A view’s dispose method removes all of its DOM elements, unsubscribes from DOM or model/collection events and calls dispose on its subviews.
    -> it will increase you page response speed.. its good practise to have in code..

  • But all your dispose function does is:

    1) Overrides the parent dispose method on that class so that instead of the parent function getting called, this will get called instead

    2) Calls is the parent dispose function for that class

    If you hadn't overriden the parent class, the parent dispose function will be called anyway, so you've added the overhead of a function with no real benefit.

    If you want to test this out, put a breakpoint in the dispose function for CreateActionsView (or its parent - I'm on 7.7, so it has been deprecated). You'll see that whether your code is there or not (or it'll get called on CreateActionsView's parent).

Reply
  • But all your dispose function does is:

    1) Overrides the parent dispose method on that class so that instead of the parent function getting called, this will get called instead

    2) Calls is the parent dispose function for that class

    If you hadn't overriden the parent class, the parent dispose function will be called anyway, so you've added the overhead of a function with no real benefit.

    If you want to test this out, put a breakpoint in the dispose function for CreateActionsView (or its parent - I'm on 7.7, so it has been deprecated). You'll see that whether your code is there or not (or it'll get called on CreateActionsView's parent).

Children
No Data