How to display parent field on sub panel record?

I have a module DC Credit Request and it has fields related to the Distribution Centre one being the name of the DC.

I also have a one to many relationship with the Item Credit Line which is a sub panel on the DC Credit request module.

I would like to display the name of the Dc for each of the Credit Lines (credit lines are for products they want a credit for). I dont want the end user to populate the line item DC name I want it to populate automatically (or show from the parent record). One of the reasons for this when users search on Credit Lines based on a product obviously there can be multiple DC's with credit requests for the product. Any suggestions would be good. Hoping its not a code fix.

Parents
  • Hi Stevan Goodchild,

    In a relationship field normally the name of the parent module is automatically filled in relate field in child module. But in your case you want to auto-populate in Item Credit Line from DC, not from DC Credit Request. So here you can do this by overriding the js controller. 

    Extend the create.js in Item Credit Line and override its render method and get the DC value from the model.

    Here is the sample code:

    ({
    extendsFrom: 'CreateView',

    /**
    * @inheritdoc
    */
    initialize: function (options) {
    this._super('initialize', [options]);
    },
    render: function (options) {
    this._super("render");

    //Here set the relate field id
    this.model.set('relate_field_id', this.model.link.bean.dc_module.id);

    //Here set the relate field name
    this.model.set('relate_field_name', this.model.link.bean.attributes.dc_module.name);
    }
    })

Reply
  • Hi Stevan Goodchild,

    In a relationship field normally the name of the parent module is automatically filled in relate field in child module. But in your case you want to auto-populate in Item Credit Line from DC, not from DC Credit Request. So here you can do this by overriding the js controller. 

    Extend the create.js in Item Credit Line and override its render method and get the DC value from the model.

    Here is the sample code:

    ({
    extendsFrom: 'CreateView',

    /**
    * @inheritdoc
    */
    initialize: function (options) {
    this._super('initialize', [options]);
    },
    render: function (options) {
    this._super("render");

    //Here set the relate field id
    this.model.set('relate_field_id', this.model.link.bean.dc_module.id);

    //Here set the relate field name
    this.model.set('relate_field_name', this.model.link.bean.attributes.dc_module.name);
    }
    })

Children