How can i preset the field value (from parent entity) of a child entity when create

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Vincent
    Senior Member
    • May 2017
    • 176

    How can i preset the field value (from parent entity) of a child entity when create

    I have 2 entities mstr and dtl and the relationship between mstr and dtl is One-to-Many.

    I add dtl to the relationship panel in mstr.
    I want to preset the value of dtl (value from mstr) in dtl create page. how can i do this? thanks

  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello,
    if you create dtl with the relationship panel, and mstr field is on the detail (small), this field will be filled

    Comment

    • Vincent
      Senior Member
      • May 2017
      • 176

      #3
      Thanks.

      I want field A of dtl to be filled by he name of the mstr when create. how can i do this, thanks.

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        If you want to fill this field on the editable form, you need to develop it (override the view of mstr field , 'select' method)
        (
        client/modules/advanced/src/views/quote/fields/account.js if you have Advanced Pack

        )

        If you want only to show the field of related entity, you can create a field with the type Foreign in Entity Manager and the field of related entity will be shown on the form, but won't be editable (readOnly)

        Comment

        • Vincent
          Senior Member
          • May 2017
          • 176

          #5
          Thanks.

          I tried Foreign field. When creating the dtl record using relationship panel, the mstr is shown in the create view of the dtl , but the field A shows None.
          After the dtl record is saved, field A is filled. But i want the field A is filled before save.

          i have also tried overriden the view of mstr field of dtl entity, 'select' method. But the mstr value is auto-filled by the system when i creating a new dtl record using relationship panel, select method has not been run.
          Last edited by Vincent; 05-09-2018, 08:54 AM.

          Comment

          • Vincent
            Senior Member
            • May 2017
            • 176

            #6
            relatedAttributeFunctions method in views/campaign/detail.js show the example of how to set the value from mstr to dlt when create
            Last edited by Vincent; 05-10-2018, 01:05 AM.

            Comment

            Working...