10 Replies Latest reply on Jul 23, 2018 4:56 PM by Thomas Righele

    Handling Object List as Input Variable

    Thomas Righele Seasoned Veteran

      Hello all-

       

      I believe the answer to this is simple, but i am having some difficulty around the syntax.

       

      I have a simple object list that I am trying to pass into a new Action in the Service connector:

       

      {

          "orders": [

              {

                  "patientid": "2594198",

                  "documentid": "19561129"

              },

              {

                  "patientid": "2594198",

                  "documentid": "19561129"

              },

          ]

      }

       

      The URL that I need to call next needs both patientID and documentID. I would like to send both orders through and output this into a new object list.

       

      From reading other documentation, I believe I need loop through the "orders" list in the Binding URL somehow. I tried multiple different things, but keep getting error messages.

       

      Can someone please point me in the right direction?

       

      Thanks,

      Tom

        • 1. Re: Handling Object List as Input Variable
          bhim mantha Guru

          Hi ,

           

          Define a PO called Order with input fields patientid and documentid

           

          The I/P to your service connector should be a list of Orders

           

           

           

           

          Sample Data

           

          <orders>

          <patientid>2594198</patientid>

          <documentid>19561129</documentid>

          </orders>

          <orders>

          <patientid>2594198</patientid>

          <documentid>19561129</documentid>

          </orders>

           

          • 2. Re: Handling Object List as Input Variable
            Thomas Righele Seasoned Veteran

            Thanks bhim-

             

            Appreciate the help. I do have this setup already where I am passing the object list as the input parameter. However, how do I refer to this in the binding tab? I have to pass the patientid and documentid in the URL of the next call. I am assuming I have to do some loop for each order.

             

            Any assistance is appreciated!

             

            Thanks,

            Tom

            • 3. Re: Handling Object List as Input Variable
              bhim mantha Guru

              Would you please post here what the API request looks like when you pass the patientid and documentid . Do you have to call the API twice if you have 2 patientId's for example ? or can you pass both of them at one shot .

               

              Thanks.

               

              -Bhim

              • 4. Re: Handling Object List as Input Variable
                Thomas Righele Seasoned Veteran

                Hello Bhim-

                 

                I was referencing this post from a user who had the same issue and was able to resolve it:

                 

                How to handle input of List of Object list in a process Service Call Step?

                 

                After creating a process object and defining the I/P as the object list that I am passing, I get to this step:

                 

                • In the binding tab - body, I included two for loops to loop through the main <links> tab and the child <link> tab based on the object list $links and $links/link@

                 

                However, I am having trouble looping in the binding Tab. Can you loop through the list using an expression and then pass this to a URL?

                 

                Thanks,

                Tom

                • 5. Re: Handling Object List as Input Variable
                  bhim mantha Guru

                  Hi Thomas ,

                   

                  Yup you can write expressions in the Binding tab . It supports XQuery expressions .

                   

                  You can also do the data transformation with in the process and then send it to a service connector . The service connector will be a pass through .

                   

                  It all depends on the use case . That is why I was asking if you had a specific API you were trying to call and how you needed to transform the data .

                   

                  I would prefer looping with in the process , as it gives me more detail at run time .

                   

                  -Bhim

                  • 6. Re: Handling Object List as Input Variable
                    Thomas Righele Seasoned Veteran

                    Thanks for the information Bhim-

                     

                    The use case is that I make one call to a system to retrieve all outstanding orders. In most cases, multiple orders are retrieved. I output this into an object list. I then need to make another call for each of those orders to gather additional details.

                     

                    The URL of the API call looks like this https://api.system.com/5622/patients/{$patientID}/documents/order/{$documentid}

                     

                    What is the best way to handle this second call to retrieve the other information?

                     

                    Additionally, can you please provide an example of an Xquery that would loop the above URL for each variable in the list?

                     

                    Thanks,

                    Tom

                    • 7. Re: Handling Object List as Input Variable
                      bhim mantha Guru

                      Thanks for that . In this case you don't need XQuery . You will use the concept of sub processes or a list pattern .

                       

                      You will create a sub process that applies to Order object . You will then inside the sub process have this API call . This will automatically iterate over the list of orders that you have . You don't need to write XQuery code for this .

                       

                      To teh second API , define patientId and documentId as I/P parameters . Uncheck the parameter option on input parameters .

                       

                      See the artifacts attached.

                      • 8. Re: Handling Object List as Input Variable
                        Thomas Righele Seasoned Veteran

                        Thanks for the information bhim-

                         

                        I've gotten as far as creating the subprocess and I can see it is iterating as many times as the amount of orders I have.

                         

                        However, the subprocess keeps sending the first order information. It is not sending the patientid and documentid of each order to the new process I created.


                        Is this because of how my input fields are configured? I simply have the patientid and documentid subprocess input as:

                         

                        Value=Content, {$output.orders[1]/patientid}

                        Value=Content, {$output.orders[1]/documentid}

                         

                        Why is it not taking the values from each of the orders? Shouldn't it be looping through the entire orders list?

                         

                        Or do I need to write formula in the input fields of the subprocess to loop through and pull the next patientid/documentid?

                         

                        Thanks!

                        Tom

                        • 9. Re: Handling Object List as Input Variable
                          bhim mantha Guru

                          Hi Tom ,

                          The sub process should automatically iterate over your list assuming your list is populated correctly .

                           

                          Would you mind sending a screenshot of your output variable and the expression for teh service connector response and teh actual data it has at run time.

                           

                          -Bhim

                          • 10. Re: Handling Object List as Input Variable
                            Thomas Righele Seasoned Veteran

                            Thank you for your help bhim. You certainly pointed me in the right direction.

                             

                            I was eventually able to figure this out after a lot of trail and error. This training video helped me out greatly:

                             

                            Training Lab 6 Demo - Automotive Services

                             

                            The part I was getting lost in was appending my results to one final list. To do this, I had to create a Temp list that I sent into the subprocess as an input. In the subprocess, I had an assignment in which I kept appending to itself each time it ran.

                             

                            list:append($input.iOrderDetailTest , $temp.getOrderDocXML )

                             

                            Once the subprocess was complete, I created a new output variable in my main process. There I assigned the output variable to my temp list. Then I was able to get my full list in one call.

                             

                            Thanks all! Hope this helps someone!

                            1 of 1 people found this helpful