5 Replies Latest reply on Jun 26, 2014 1:51 PM by philmodjunk

    Mirroring records from one portal to another

    tays01s

      Title

      Mirroring records from one portal to another

      Post

      I never got to the bottom of a previous post: Portals: Mirroring


            

      In this I have the following relationships:

      Drugs----<Druglist_rx>-----Prescriptions-----<Input----<Druglist_in>---Drugs|Input


            

      I want to prescribe a DrugList_rx. When I add a new 'Input' I want to automatically generate/mirror this list in 'Druglist_in' where I can specify the actual input as opposed to what had been prescribed.


            

      It was suggested to try:

      Set Variable [ $ID; Value:Patient::Prescription_n ]

      Freeze Window

      Go to Layout [ “Input” (Input) ]

      New Record/Request

      Set Field [ Input::_PrescriptionID; $ID ]

      Set Variable [ $List; Value:Druglist_rx::__DrugList_rxID ]

      Go to Layout [ “Druglist_rx” (Druglist_rx) ]

      Freeze Window

      Loop

      Set Variable [ $K; Value:ValueCount ( $K+1 ) ]

      Exit Loop If [ $K>ValueCount ( $List ) ]

      New Record/Request

      Set Field [ Druglist_in; GetValue ( List (Druglist_rx::__DrugList_rxID) ; $K) ]

      End Loop

      Go to Layout [ “L_Patient Copy” (Patient) ]

            

      Its fine till: Go to Layout [ “Druglist_rx” (Druglist_rx) ]

      then gets stuck in the loop generating endless Feedlist_rx records.

        • 1. Re: Mirroring records from one portal to another
          philmodjunk

               Are you performing this script via a script trigger?

               If so, disable that script trigger and run this script by clicking a button on your layout.

               Let me know if that works. (Go to Layout  is notorious for tripping any number of different script triggers on either the layout being exited or the layout being entered by the execution of that script step.)

          • 2. Re: Mirroring records from one portal to another
            tays01s

                 It is performed via a button: Button setup set to 'perform script', Options of current script set to 'pause'.

            • 3. Re: Mirroring records from one portal to another
              philmodjunk

              Set Variable[$K; Value:ValueCount ( $K+1 )]

              should be:

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

                   Apologies if that was due to an error on my part in the original thread.

                    

              • 4. Re: Mirroring records from one portal to another
                tays01s

                     Thanks.

                     I get an 'This operation cannot be performed because one or more required related records are not available or cannot be created.' warning. Once I press OK the Input record is generated as expected, the endless loop is dealt with but the prescription isn't 'mirrored' in the Druglist_in portal (or anywhere).

                      

                     In the relationship of Input < Druglist_in I have to allow creation of records in Druglist_in for the fields to appear in the portal in Browse; otherwise they don't appear. I can add any number of records into the Druglist_in portal and if I transfer to another Input record and do the same thing, then come back, the records to appear in Druglist_in under the first Input record.

                      

                     Portals have the following filters specified:

                     Druglist_rx: Feedlist_rx::_PrescriptionID=Patient::Prescription_n

                     Druglist_in: Feedlist_in::_InputID=Patient::Input_n

                • 5. Re: Mirroring records from one portal to another
                  philmodjunk

                       No portal filters should be needed as far as I can tell form here and portals could keep things from working here. What you show as "filters" look like what should be set up as match fields defined in the relationships in Manage | Database | Relationships.

                  Drugs----<Druglist_rx>-----Prescriptions-----<Input----<Druglist_in>---Drugs|Input

                       Set Variable [ $ID; Value:Patient::Prescription_n ]
                       Freeze Window
                       Go to Layout [ “Input” (Input) ]
                       New Record/Request
                       Set Field [ Input::_PrescriptionID; $ID ]
                       Set Variable [ $List; Value:Druglist_rx::__DrugList_rxID ]
                  Go to Layout [ “Druglist_rx” (Druglist_rx) ]
                       Freeze Window
                       Loop
                           Set Variable [ $K; Value:  $K+1  ]
                           Exit Loop If [ $K>ValueCount ( $List ) ]
                           New Record/Request
                      Set Field [ Druglist_in; GetValue ( List (Druglist_rx::__DrugList_rxID) ; $K) ]
                       End Loop
                       Go to Layout [ “L_Patient Copy” (Patient) ]

                       Notice the two steps in Blue. The first specifies a layout based on DrugList_rx and so New Record/Request creates a new record in that table. Bu the second step attempts to modify the value of a field from Druglist_in. That makes no sense and is the source of the error message that you report.

                       The first line in blue should be:

                       Go to Layout ["Druglist_in" ( Druglist_in ) ]
                       The second line is also incorrect. the calculated value should be: GetValue ( $List ; $K )