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.

  • 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) {

    //Here set the relate field id

    //Here set the relate field 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.  

  • If I  understand correctly DC Credit Request has the Distribution Centre Name as one of its fields. The Item Credit Line is uniquely related to a DC Credit Request, and you want the DC Name on the Item Credit Line.


    If that is so you can go to the module for Item Credit Line in Studio, and add a calculated field that copies the DC Name from the related DC Credit Request.

    Because it's a calculated field it will be read only.



  • Hi Francesca

    I have tried solution you have suggested and it works fine for new credit lines. Is there a way that it can grab the store name for existing credit lines?

  • If you go to the list view of your credit lines you should be able to select all lines and choose the option in the dropdown to recalculate calculated fields (Sorry, I don't have Sugar in front of me and I don't remember what it's called exactly - it's in the same menu as the mass update).

    If you have a lot of credit lines I suggest you do it in batches, you don't want to overload your system.


  • Thank you for the quick reply Francesca and really appreciate all the effort from both you and Maryam.

    Unfortunately it would appear our version doesn't have that ability (6.5.17) we were going to upgrade but the business has decided on another system - sad to say as I am just getting to grips with Sugar. Its just not going to happen for about three months. 

  • Sorry about that, v7 and up are soooooo much better than v6, it's a different world. 

    If the solution works for new records then it should also work when a record is saved again. Editing and re-saving every record would be very laborious but I can't think of another way unfortunately.