4 Replies Latest reply on Jun 8, 2014 11:47 PM by tays01s

    Duplicate portal row

    tays01s

      Title

      Duplicate portal row

      Post

           I must be missing a vital script line because the script duplicates OK, but if I've changed 'patient' (parent table), say patient B to A, since the last 'calc' record, then duplicate, gives me a duplicate of the last patient B Calc record, not the last related patient A calc record.

      Duplicate_Calc_record_script.jpg

        • 1. Re: Duplicate portal row
          philmodjunk

               You need scripting that pulls up the correct record on your "calc" layout. Just changing layouts just goes to whatever record is the "current" record on that layout. What patient is current on your "L_Patient" layout has no effect on what record is current on the other layout in you current design.

               Try replacing Go to layout with:

               If [ Not IsEmpty ( calc::_PatientID ) ]
                  Go To Related Record [Show only related records; From table: calc; Using layout: "calc" (calc) ]
                  Duplicate Record/Request
               Else
                   Show Custom Dialog ["There is no calc record linked to this patient record"]
               End If

               Note, since the record you are duplicating is already linked to the current patient record, the _patientID field already has the needed matching value that you need to link the new record to the same patient. Thus, there should be no need for the set variable, set field steps in your original script when using this new version.
                

          • 2. Re: Duplicate portal row
            tays01s

                 This duplicates but after the first duplicate, it duplicates the first related record (correct). I need it to duplicate the latest related record.

                  

                 If there's no record nothing happens, namely because I'm not sure what do with the

                 Show Custom Dialog ["There is no calc record linked to this patient record"]

                 However, I'm really just wanting a blank record (portal row) if there's no related record in that portal. So, I instead but after the 'Else', 'go to calc layout, new record' then finish with the 'End if'? The latter seemed to work OK.

                  

            • 3. Re: Duplicate portal row
              philmodjunk

                   You can add a

                   Go to Record/Request/page [Last]

                   Step to go to the last/most recently created record related to the current.

                   Creating a new blank record when none exists, works as long as you use set variable/set field to copy over the necessary primary key field value (as you did in your original script), to link it to your current patient record.

              • 4. Re: Duplicate portal row
                tays01s

                     Yes, that works well, thanks.