AnsweredAssumed Answered

Creating Related Records From A script

Question asked by alanfair on Sep 29, 2012
Latest reply on Oct 1, 2012 by alanfair


Creating Related Records From A script


     I am still new to scripting, but seem to have an issue where i need to create two related records when i create a record in the main table and then present the data for editing by the user.

     I have broken the issue down to its basics. I have two tables as below

Table = Inspections


in_id  - numeric, serial numbered Auto created

in_description  , text, required value

Table = Data

     d_id - numeric, serial numbered, Auto created

     d_inspection_id, numeric - holds the inspection number from in_id

     d_data - text

     The tables are related by in_id and d_inspection_id

     So I have started to created a script to create a new inspection record then the data records, for this example i will attempt to create just one, data record. My script is

     go to layout ["Inspections" (Inspections)]

     New Record/Request

     Set Variable [$$InsNumber; Value:Inspections::in_id]

     go to layout ["Data" (Data)]

     New record/request

     Set Field [Data::d_Inspection;$$InsNumber]

     go to layout ["Inspections" (Inspections)]

     However the script goes all wrong, when i attempt to go to the data layout, as it will not let me move off, the inspection layout, as the in_description field is a required field, so i get prompted to enter something in this field.

     Now i know this must be a common requirement, but my looks around the forum etc have just let me confused as to how to do this.

     So the question is, how do i go about creating a number or related records, ahead of presenting the data to the user to enter.  I have to create the inspection record to get its unique number to then supply this to the related records. But I cannot move away from the inspection record until all the necessary required data has been entered, which at this point it time it has not.

     Perhaps I am coming at this from the wrong angle, - So Help !!