You are viewing limited content. For full access, please sign in.

Question

Question

collection fields, multi-value token & Webservice

asked on August 16, 2020

I have a form set up to capture types of income from various people in a group.  so 2 people in a group--jon and jane--jon smith might have one or more income sources with amounts and jan doe might also have one or more incomes.  the form is set up as a collection 

the workflow is retrieving business process variables and appears to be retrieving all the values for the various variable.  

workflow (see below) i want to look through each person and get each income source.  Then i need it to send that information to a webservice.  it seems from the track tokens that i've thrown in that it is getting data correctly and it seems like the for each row is working, but when i put it into the webservice it doesn't seem to work.  if i 'hard code' the information in the webservice call it works fine.  So the best i can figure is that it doesn't like something about the way it is passing the token?

 

 

 

0 0

Replies

replied on August 17, 2020

UPDATE

following ALMOST works.  BUT IS ONLY CREATING the record for the LAST value in the collection.  so it is only creating the income source record for the last member of the household

WHERE THE DEMO API call that is inside the for each row is 

[
{
 "memberID": %(MemberID#[%(ForEachRow_Iteration)]#), 
"incomesourceID":%(SSIIncomeID),
"amount": %(SSI#[%(ForEachRow_Iteration)]#)
}
]

 

 

 

0 0
replied on August 18, 2020

In your screenshot, your Demo API activity is outside the For Each Row loop.

0 0
replied on August 18, 2020

i tried it both inside and outside of the for each row loop.  when it is inside the for each row loop it is creating multiple records that it shouldn't create.  

 

how do i get the multi-value to create multiples of just this part based on the loops.

 

so if there were 2 people with 2 incomes, then there would be 4 records inside the []

[
{
 "memberID": %(MemberID#[%(ForEachRow_Iteration)]#), 
"incomesourceID":%(SSIIncomeID),
"amount": %(SSI#[%(ForEachRow_Iteration)]#)
}
]

 

0 0
replied on August 18, 2020

This snippet of JSON would only work inside the loop as you're using %(ForEachRow_Iteration) to indicate which value to pick. This token has no meaning outside of the loop. If you have Demo API inside the loop, then you are making multiple calls to the external API (one for each loop iteration), so that is expected behavior.

What does your webservice expect to be passed when you have more than one memberID?

0 0
replied on August 18, 2020

I'm sorry, i'm not being 100% clear.  when i move the Demo API call outside of the loop.  i did this.  

[
{
 "memberID": %(MemberID), 
"incomesourceID":%(SSIIncomeID),
"amount": %(SSI)
}
]

and the result is the last MemberID in the collection comes in correctly.

 

The end point expects something like...

[
{
 "memberID": 100, 
"incomesourceID":1,
"amount": 450.50
},

{
 "memberID": 100, 
"incomesourceID":5,
"amount":800
},

{
 "memberID": 200, 
"incomesourceID":1,
"amount": 50.50
},

{
 "memberID": 200, 
"incomesourceID":5,
"amount": 300
}
]

0 0
replied on August 18, 2020

Build each block in For Each and append it to a multi-value token.

{
 "memberID": %(MemberID#[%(ForEachRow_Iteration)]#), 
"incomesourceID":%(SSIIncomeID),
"amount": %(SSI#[%(ForEachRow_Iteration)]#)
}

(without the square brackets. You can leave out the line breaks)

Then in your Demo API set the content body to
 

[

%(Multiline token of individual members#[,]#)

]

That will put in all values and separate the blocks by commas.

0 0
replied on August 19, 2020

Thank you!  Took some adjustments, but this is almost working.

How do i indicate in that if a certain token value is empty, then leave a set of elements out of the Multi-line token of individual members?

 

so for example if member does not have any employment income, then i don't want to create

{
 "memberID": %(MemberID#[%(ForEachRow_Iteration)]#), 
"incomesourceID":%(employmentIncomeID),
"amount": %(employment#[%(ForEachRow_Iteration)]#)
}

... right now it is creating it but not putting any values in it

0 0
replied on August 19, 2020

Thank you!  Took some adjustments, but this is almost working.

How do i indicate in that if a certain token value is empty, then leave a set of elements out of the Multi-line token of individual members?

 

so for example if member does not have any employment income, then i don't want to create

{
 "memberID": %(MemberID#[%(ForEachRow_Iteration)]#), 
"incomesourceID":%(employmentIncomeID),
"amount": %(employment#[%(ForEachRow_Iteration)]#)
}

... right now it is creating it but not putting any values in it

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.