1 Reply Latest reply on Oct 29, 2014 6:43 AM by philmodjunk

    create record in different table

    BillPlunkett

      Title

      create record in different table

      Post

      The best way to pose the question is to fully describe what I want to do.  I have an application that documents board meetings for an association.  The base table for the layout is "Meetings".  There is a related table named "Attendance" and another related table named "Trustees".  On the layout is a portal to the Attendance table with Trustees Names and a checkbox to indicate if they are present or not.  What I want to do is when they create a record in Meetings for a new meeting, I want to populate the Attendance table with records for each Trustee for the current meeting.  Then all they must do is, for each trustee, indicate if they are present or not.

      So how do I read each record in the Trustee table and create a record for the new meeting in the Attendance table?

      thanks,

       

       

        • 1. Re: create record in different table
          philmodjunk

          a ) Perform a find to pull up a found set of trustee records on a trustee layout and loop through them using the data in these records to create new records in your portal's table with the needed match field values so that the trustee names appear.

          b) Capture a return separated list of the needed data from the trustee table via a relationship or executeSQL and loop through the values of the list while creating new records.

          c) Set up a relationship like this:

          Meetings::AnyField X Trustees::anyfield

          Trustees::TrusteeID = Attendance::TrusteeID AND
          Trustees::gMeetingID = Attendance::MeetingID

          gMeetingID is a global field. Using the OnRecordLoad trigger on your Meetings layout to perform this script:

          Set Field [Trustees::gMeetingID ; Meetings::MeetingID ]

          You keep the records correctly linked. You can now set up a portal to Trustees and include your check box field from Attendance in the portal row of this portal. As long as "allow creation of records via this relationship" is enabled for Attendance in the trustees to attendance relationship, this should work without the need for any scripting other than the single set field script to update the global field in Trustees.