2 Replies Latest reply on Aug 19, 2013 1:57 AM by DavidDuncan

    Related Record question



      Related Record question


      Is it possible to write a script to go to the related record but if no related record is found to do a new record request? I'm trying to do away with a two button approach. Currently I have one button that lets me add to my collection by by doing a new record request and one button to add to the existing record by the related record method. It would be more functional if I could have one button that would search for the related record but if it wasn't found then it would do a new record request. Thank you for any help.

        • 1. Re: Related Record question

          From the Parent record's layout you can check for the existance of related records:

          If [ Not IsEmpty ( RelatedTable::FieldThat'sNeverEmpty ) ]
             Set Variable [$PrimaryKey ; ParentTable::Primarykey ]
             Go To layout [ Layout for related table ]
             New Record/Request
             Set Field [ RelatedTable::ForeignKey ; $PrimaryKey ]
             Go To Related Records [
          End IF

          Of course, with a portal to the related table, you can also view and create related records directly from the parent table's layout.

          • 2. Re: Related Record question

                 Hi all

                 I followed earlier advice from PhilModJunk in response to a question about how to create a new related record with an auto-populated ID field. Similar to this one, but without the IF, THEN. That was working, but I then came across the problem that Reggie describes if I wanted to go back to the Layout (i.e., it tried to create another new record)

                 I have now modified my script to follow the example above from PhilModJunk, as follows:


                      If [Not IsEmpty(RelatedRecord::ID field)]


                           Set Variable[$ID; Value:ParentRecord::ID field]


                           Go to Layout [“RelatedRecord” (ChosenLayout)


                           New Record/Request


                           Set Field [RelatedRecord::ID field; $ID]




                      Go to Related Record [From table: “RelatedRecord”; Using layout: “RelatedRecord” (ChosenLayout)]


                      End If

                  However, I am still getting a new blank record created even if that record already has been created.  Can anyone see where I might be going wrong?