How to get a field auto populate from another module's (from subpanel view) field on create view?

I need to get a field from a module and set the value of this field on the name field when I'm creating a new record. For example, in a custom module, we have a field called "work product", when we are creating a new record in subpanel module we want to show the consecutive value (from our custom module) on the work product field. 

Below is the code : 

({
    extendsFrom: 'CreateView',
    initialize: function (options) {
        this._super('initialize', [options]);
        this.on('render', _.bind(this.onload_function, this));
    }, 
  onload_function: function () {
    var parent_model = App.controller.context.get('model');
      var parentId = parent_model.get('id'); // It will get parent record id
      var parentname = parent_model.get('_module');	  // It will get parent record name
      alert(parentId);alert(parentname);
    
       if(parentname == 'GD_Group_Design')
        {
           var parent_wp = App.controller.context.get('model').get('m03_work_product_gd_group_design_1_name');
           alert('parent_wp ' + parent_wp);
           this.model.set('m03_work_product_taskd_task_design_1_name',parent_wp); //a simple set statement takes care of selecting the option on the dropdown
        } 
       
        
   },
 
})

Although i am getting the field value from parent module but  it's showing the below error when i am trying to create new record from subpanel view using + button .

this.context.parent.get(...).get is not a function at ....

Parents
  • This is easily accomplished by defining the attribute 'populate_list' at extended vardefs of parent module.

    For example, if the link definition for child (subpanel) module on parent modules vardefs is "m03_work_product_taskd_task_design_1" then the code may looks like that:

    $dictionary['<ParentClass>']['fields']['m03_work_product_taskd_task_design_1']['populate_list'] = [
        'm03_work_product_gd_group_design_1_name' => 'm03_work_product_taskd_task_design_1_name',
    ];
    

    Remember to run QRR after saving the extended vardefs.

    André Lopes
    Lampada Global
    Skype: andre.lampada
Reply
  • This is easily accomplished by defining the attribute 'populate_list' at extended vardefs of parent module.

    For example, if the link definition for child (subpanel) module on parent modules vardefs is "m03_work_product_taskd_task_design_1" then the code may looks like that:

    $dictionary['<ParentClass>']['fields']['m03_work_product_taskd_task_design_1']['populate_list'] = [
        'm03_work_product_gd_group_design_1_name' => 'm03_work_product_taskd_task_design_1_name',
    ];
    

    Remember to run QRR after saving the extended vardefs.

    André Lopes
    Lampada Global
    Skype: andre.lampada
Children
No Data