2 Replies Latest reply on Jun 2, 2015 7:20 AM by jkostenbader

    Adding a record on the Many side of a relationship

    jkostenbader

      Title

      Adding a record on the Many side of a relationship

      Post

      Not sure this is titled correctly but here's my basic question. I have two tables...Employees and Comments. There  is a one-to-many relationship between employees and comments (each employee can  have many comments) and its set up properly. On the employees layout there is a portal that lists the many comments and one of the buttons on the portal row allows me to navigate to a comments layout where you can see a larger window for extended comments. Having the employee ID in the comments table allows me to do a lookup and draw in the employee full name. 

      Ideally I'd like to have a popover window on the comments layout that lists all the employees and allow me to generate a new comment right from the comments layout. Right now the popover has a portal on it and through a Cartisian join back to the comments table I have a list of employees displaying but that's where I'm stuck. I'm not sure how to populate the employee ID in the comments table with a button

      Hopefully that explaination wasn't too long and I didn't leave out a relevant details. Any help would be appreciated

      John

       

      6-1-2015_1-07-59_PM.png

        • 1. Re: Adding a record on the Many side of a relationship
          philmodjunk

          My guess is that you want to click a row in the portal and create a new comments record with the ID of the clicked portal row.

          Set Variable [$ID ; value: T10_AddEmployeeToComment::ID_Employee ]
          New Record/Request
          Set FIeld [T40_Comment::ID_Employee ; $ID ]

          If you don't want to create a new comment record, just attach the current comment record to the Employee whose portal row was clicked, you only need:

          Set FIeld [T40_Comment::ID_Employee ; T10_AddEmployeeToComment::ID_Employee  ]

          Note that you can select all the fields in the portal row while in Layout Mode and then use Button Setup to turn the selected fields into a button to perform this script. Or you can place a transparent rectangle on top of the fields and set it up as your button (which can produce different "hover" appearance changes not possible with just the fields grouped into a button.)

          • 2. Re: Adding a record on the Many side of a relationship
            jkostenbader

            That worked like a charm...thank you so much. You've saved me hours of experimentation.