Default value in a multiselect inherited from a field in another module

Hi all

I think I´ve seen an answer to this but can´t find it now - maybe I just dreamt it 

I have a multiselect field on the Contacts record (field B).

The same dropdown list is in a field on the Accounts record (field A).

When creating a new Contact, I want to give field B a default value that is the same as in the field A (on it´s Accounts related record). Basically field B = field A at that point.

How can I achieve taht?

Thanks,

KGM

Parents
  • Hi Kristjan Geir Mathiesen

    Can you try this and let me know.

    While creating a dropdown you will be giving a name, with that we can manage.

    this.model.fields['FieldB or FieldA'].options = app.lang.getAppListStrings('your-dropdownlist-name');  

    Let me know for further Help..

    Here is the full code example;

    ({ extendsFrom: 'CreateActionsView',  
        initialize: function (options) {        
            this._super('initialize', [options]);      
            this._filterDropdown(); 
        }, 
        _filterDropdown : function() { 
            this.model.fields['FieldB or FieldA'].options = app.lang.getAppListStrings('your-dropdownlist-name'); 
        }, 
        _dispose: function() {  
            this._super('_dispose');  
        }      
    }); 

    Hope this Helps..!!

    Best Regards

    S Ramana Raju

Reply
  • Hi Kristjan Geir Mathiesen

    Can you try this and let me know.

    While creating a dropdown you will be giving a name, with that we can manage.

    this.model.fields['FieldB or FieldA'].options = app.lang.getAppListStrings('your-dropdownlist-name');  

    Let me know for further Help..

    Here is the full code example;

    ({ extendsFrom: 'CreateActionsView',  
        initialize: function (options) {        
            this._super('initialize', [options]);      
            this._filterDropdown(); 
        }, 
        _filterDropdown : function() { 
            this.model.fields['FieldB or FieldA'].options = app.lang.getAppListStrings('your-dropdownlist-name'); 
        }, 
        _dispose: function() {  
            this._super('_dispose');  
        }      
    }); 

    Hope this Helps..!!

    Best Regards

    S Ramana Raju

Children
  • Hi Ramana Raju Santhana

    Thanks for a speedy reply

    I´ve got 3 questions:

    1) The name of the field (in Contacts) that is to inherit the value from Account is target_group_contact_c 

    The name of the field (in Account) is target_group_c

    The name of the list is target_group_list

    Is this code then correct?

    ({ extendsFrom: 'CreateActionsView',  
        initialize: function (options) {        
            this._super('initialize', [options]);      
            this._filterDropdown(); 
        }, 
        _filterDropdown : function() { 
            this.model.fields['target_group_c'].options = app.lang.getAppListStrings('target_group_list');  
        }, 
        _dispose: function() {  
            this._super('_dispose');  
        }      
    }); 

    2) Sorry but I´m new at this extending stuff   

    What is the name of the file the above code go into?

    Do I copy that file or create a new, empty one with that name?

    And what is the path of the extended file?

    3) These are actually MultiSelect fields (not Dropdown), should I then change:

    this._filterDropdown(); to -> this._filterMultiselect();
    and
    this._filterDropdown(); to -> this._filterMultiselect();

    ?

    Thanks so much,

    KGM 

  • Hi Kristjan Geir Mathiesen

    For Question 1: 

    If you want target_group_list  to field target_group_contact_c then do as:

    ({ extendsFrom: 'CreateActionsView',  
        initialize: function (options) {        
            this._super('initialize', [options]);      
            this._filterDropdown(); 
        }, 
        _filterDropdown : function() { 
            this.model.fields['target_group_contact_c'].options = app.lang.getAppListStrings('target_group_list');  
        }, 
        _dispose: function() {  
            this._super('_dispose');  
        }      
    }); 

    For Question 2:

    Keep this code in

    custom/modules/Contacts/clients/base/views/create.js file

    For Question 3:

    No need of changing to Multi or Dropdown, we can give any name..

    Hope this Helps..!!

    Best Regards

    S Ramana Raju