Create Records with API & Webhook

I am trying to create Child records, EstimateDetails, when an Estimate is created. Each Estimate is for a Structure that consists of multiple stages. I can do this with looping but it takes a long time. I am trying to do it on the server using the API & Webhook call. I have the following call formatted:
{
"Action": "Add",
"Properties": {
"Locale": "en-US"
},
"Rows": [
<<START: [Estimate_Structure].[Structure_Stages]>>
{
"EstDet_EstimateLink": "<<[_thisrow-1].[Estimate_ID]>>",
"EstDet_Stage": "<<[_thisrow-1].[Estimate_Structure].[Structure_Stages]>>"
}
<<END>>
]
}
I know that the EstDet_Stage value is incorrect as it is throwing an error & trying to add the list of Stage_IDs in the EstDet_Stage field which takes a single value. I am at a loss as to how to get the loop to insert the value of the current iteration into the row values. Any tips are appreciated. Thanks

Solved Solved
0 7 123
1 ACCEPTED SOLUTION

I normally do this from an additional looping table that doesn't have anything to do with the data itself. Lets assume you have one table with one column (number type) and then numbers like 1, 2, 3..,10. Then you can have max 10 loopings.

Instead of looping the webhook/API from your data table, loop it from this "Looping" table. You just need to use something like <<START: ORDERBY(SELECT(Loopings[Number],[Number]<=COUNT("HowManyRecordsYouShouldAdd")),[Number],FALSE)>>

Then you can read the number for the INDEX() from that row's [Number] column.

View solution in original post

7 REPLIES 7

I normally do this from an additional looping table that doesn't have anything to do with the data itself. Lets assume you have one table with one column (number type) and then numbers like 1, 2, 3..,10. Then you can have max 10 loopings.

Instead of looping the webhook/API from your data table, loop it from this "Looping" table. You just need to use something like <<START: ORDERBY(SELECT(Loopings[Number],[Number]<=COUNT("HowManyRecordsYouShouldAdd")),[Number],FALSE)>>

Then you can read the number for the INDEX() from that row's [Number] column.

Thanks Aleksi, I will give this a try.

You're welcome!

I am using this to generate the Start expression: SORT(SELECT(Looping[Looping_Index], ([Looping_Index] <= COUNT([Estimate_Blueprints]))))>>
However it is generating a list of my indices & I should be starting with a list of records IDs to loop through, then use the index to grab the correct record from the list

Hi @AleksiAlkio thank you for the tip, I have used this expression now to create the correct records:
{
"Action": "Add",
"Properties": {
"Locale": "en-US"
},
"Rows": [
<<START: ORDERBY(SELECT(Looping[Looping_Index], [Looping_Index] <= COUNT([Estimate_Blueprints][Blueprint_Stage])), [Looping_Index], false)>>
{
"EstDet_EstimateLink": "<<[_thisrow-1].[Estimate_ID]>>",
"EstDet_Stage": "<<INDEX([Estimate_Blueprints][Blueprint_Stage],[Looping_Index])>>"
}
<<END>>
]
}
Success!

Good to hear!

@bradlegassick For reference: Appster would know this as "Parallel Processing Records"

Public Answer Portal Resource 

 

Top Labels in this Space