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);
    }
    })

  • Hi Maryam, 

    I was hoping that because I have one to many relationship DC Credit Request to many Credit Lines. I wanted to view the DC name that is in the DC Credit Request to display in the associated Credit Line. I naturally assumed because I have a relationship then it should be just a matter of selecting it in the the Creditline via  Module Builder - is this correct? I really don't want to create any code to have this displaying. Obviously I am a new to this system so any help would be really appreciated.  

Reply
  • Hi Maryam, 

    I was hoping that because I have one to many relationship DC Credit Request to many Credit Lines. I wanted to view the DC name that is in the DC Credit Request to display in the associated Credit Line. I naturally assumed because I have a relationship then it should be just a matter of selecting it in the the Creditline via  Module Builder - is this correct? I really don't want to create any code to have this displaying. Obviously I am a new to this system so any help would be really appreciated.  

Children
No Data