TeamDesk Knowledge Base & Support

   Home      FAQ      Forum      Idea Exchange      Ask a Question      My Stuff      Help   
  
Multi-Record on single api call
Hi Folks, I'm thinking of say an Order table with multiple related Order Items. I'd like to tick a few items and make a single call (POST) with those few. Multi Record Button from the items table will make a POST per item ticked rather than a single POST so I thought to populate a Multiline field on the order table from those Items ticked eg ([VariableField]&[Item]).
But I'm stuck on how to run a single trigger on the Order table (I'd rather not use a button) after the Multi-Record processing has done its last record
Any Ideas? or am I barking up the wrong tree here.
ID
1947
Category
Integration/API
Author

Robert Dykstra
Date Created
11/21/2022 4:26:12 PM
Date Updated
11/22/2022 12:20:36 AM
Comments
basenine 11/21/2022 5:08:04 PM
Hello Robert,
If the API call is going to something like Xero (where an order with items can be POSTed to create an Invoice), you can:
> Create an Array in the Line Items table (using a Formula - Text field)...like
"{"&
'"Description": "'&List(" ",[FIELD NAME],[FIELD NAME],[FIELD NAME])&'", '&
'"Quantity": "'&Format([QTY])&'", '&
'"UnitAmount": "'&JSONFormat([COST])&'", '&
'"TaxType": "OUTPUT"'&', '&
'"LineAmount": "'&JSONFormat([TOTAL COST])&'", '&
'"AccountCode": "200"}'

>Make a summary of this field in the Order Table with a match condition of Items you wanted to select.
>Use this summary field in the API body and place it in the "LineItems:" array...
"LineItems":[
{
"Description": "COULD BE ANYTHING GOES HERE....COULD BE NOTHING (IF NOTHING, DELETE EVERYTHING BETWEEN AND INCLUDING "{},")"
},
<%=[LineItemArray]%>
]

I hope this helps...and that I'm not barking up the wrong tree, too 🙂

Robert Dykstra 11/21/2022 6:15:30 PM
@Basenine, Thanks skipper, thats a better way of doing what I had, but my main issue is really around triggering that call to run once only after some of the items have been updated. I could select/edit a couple of items but the call would loop for each item. I feel like I'd need to increment +1 a PO field with each loop so the call triggers when the loop count = the number of items selected but there seems to be no way to know how many items are selected
basenine 11/21/2022 6:20:50 PM
Hello Robert,
No problems 👍

Rather than running the call at the Items table level, can you run it at the Orders table level?
The method I described runs at the Orders Table.
So the Items can be created/updated and you can add a filter on those (a simple checkbox) where the summary in the Orders Table only picks up items which are checked.
Robert Dykstra 11/21/2022 6:48:41 PM
@Basenine,
I'm picking the selected items up into the Orders table summary, no problem, by checking their modified date is less than 20 seconds old, so I've got nice array built. But I've not got a way to trigger the call in the Order table as no physical field updates, (I'm trying to avoid needing a button)
and if an Items to Orders field did update, it would update multiple times triggering the call multiple times also
basenine 11/21/2022 7:17:05 PM
Hello Robert,

I'd ask myself, "If there were an executable button, when would I press it?".
If the criterion is too complex or too loose (ie it gets pressed subjectively rather than objectively), then there may be no way to perform such a task.

> But I've not got a way to trigger the call in the Order table as no physical field updates
With this, can you make a trigger in the items table which updates a specific field in the order which then triggers the API call? You'll need to set the "Execute Triggers" to yes, if this is the case.
Robert Dykstra 11/22/2022 12:20:36 AM
@Basenine
Thanks Champ, might have to stick a pin in this one and go with an update button for now. Updating the order table field from the items multi-record ends up updating that Order field multiple times and triggering the order call multiple times.
Feedback
Back to Search Results