AnsweredAssumed Answered

Generating a series of new or updated records

Question asked by tays01s on Oct 10, 2015
Latest reply on Oct 12, 2015 by tays01s

I have some related tables:

Patient < Calc < IO < Nut_calc > Nut_eq

also relationships using TOs:

IO::__uuID = Nut_calc::_IOuuID &

Patient::IO_n = IO 2::__uuID &

Patient::IO_n = Nut_calc 2::_IO


From a Patient table layout, using a 'button script' in an IO 2 portal I want a set of 51 Nut_calc records. These should be new where none exist for an IO 2 record or if a set already exist, they should be updated. Each Nut_calc field is evaluated from a text equation on Nut_eq.


If there are no Nut_calc records, new records and evaluations are done perfectly. However, after the first set of records, the 2nd loop fails to update old records or set the fields for new records.


Set Field [ Patient::IO_n; IO 2::__uuID ]

Set Variable [ $nutcalc_ioID; Value:Patient::IO_n ]

Commit Records/Requests [ No dialog ]

Go to Layout [ “Nut_calcs” (Nut_calcs) ] {without this line, focus stays on patient > generates new patient records}

If [ IsEmpty (Nut_calcs 2::_IOuuID) ]


Set Variable [ $i; Value:$i+1 ]

Exit Loop If [ $i = 52 ]

New Record/Request Set Field [ Nut_calcs::__uuID; Get(UUID) ]

Set Field [ Nut_calcs::_IOuuID; $nutcalc_ioID ]

Set Field [ Nut_calcs::_Nut_eqsID; $i ]

End Loop

End If


Go to Related Record [ From table: “Nut_calcs”; Using layout: <Current Layout> ] [ Show only related records ]

Go to Record/Request/Page  [ First ]

Loop If [ Nut_calcs::_IOuuID = Patient::IO_n ]

Set Field [ Nut_calcs::Nut; Nut_eqs::Nut ]

Go to Record/Request/Page [ Next; Exit after last ]

End If End Loop


Go to Layout [ “Patient_L” (Patient) ]