I have a series of parent child portals whose records are created/ deleted from scripted buttons. This all works fine until I delete all records from all tables except Patient. I then find that the scripts (eg below) instead of creating a new record within the portal, instead create a new patient.
Relationships: Patient < Calc < Prescription. I have NOT activated create/delete via the relationships because I want everything to work via the scripts.
Perform Script [ “Allow user abort” ]
Go to Object [ Object Name: "calc" ] If [ not IsEmpty (Calc::_PatientID) ]
Go to Related Record [ From table: “Calc”; Using layout: “Calc” (Calc) ] [ Show only related records; Match found set ]
Go to Record/Request/Page [ Last ]
Set Variable [ $ID; Value:Patient::__PatientID ]
Go to Layout [ “Calc” (Calc) ]
Set Field [ Calc::_PatientID; $ID ]
Go to Layout [ “L_Patient Copy” (Patient) ]
Go to Object [ Object Name: "calc" ]
Go to Portal Row [ Select; First ]
Perform Script [ “Select Calc Prescription” ]
Perform Script [ “New_prescription” ]