Webhook to do batch adds error 400

I am using a "call a webhook task" when a record is created to generate a set of predefined child tasks

This body Works and will generate the correct number of child records, but only referencing the hard coded component_master_id

 

 

{
"Action": "Add",
 "Properties": {
    "Locale": "en-US",
    "Timezone": "Central Standard Time"
  },
 "Rows": [
    <<Start: Filter(component_master, CONTAINS([pump_type], [_THISROW].[asset_id].[tri_or_quint]))>>
{
      "maintenance_event_id": "<<[_THISROW].[id]>>",
      "component_master_id": "4379e5e7",
      "changed_dropdown": "N",
      "edit_increment": 0
},
    <<End>>
]
}

 

 

but when i change line 11 it gives me and error 400 and does not create any rows, the bot is successful though in this case. Any ideas on what is going on here. The payload actually looks correct in the log, and I don't have any valid if constraints or anything that might cause it not to work that I can think of.

 

 

{
"Action": "Add",
 "Properties": {
    "Locale": "en-US",
    "Timezone": "Central Standard Time"
  },
 "Rows": [
    <<Start: Filter(component_master, CONTAINS([pump_type], [_THISROW].[asset_id].[tri_or_quint]))>>
{
      "maintenance_event_id": "<<[_THISROW].[id]>>",
      "component_master_id": "<<[id]>>",
      "changed_dropdown": "N",
      "edit_increment": 0
},
    <<End>>
]
}

 

 

Kyle_Love_0-1644388795052.png

Component Events

Kyle_Love_0-1644517752071.png

Kyle_Love_1-1644517774991.png

Maintenance Events:

Kyle_Love_2-1644517817191.png

Kyle_Love_3-1644517839703.png

Component Master

Kyle_Love_4-1644517901482.png

Kyle_Love_5-1644517918249.png

 

 

 

 

0 5 172
5 REPLIES 5

My understanding of the START expression is that it adds another layer of scope from the data change that this webhook is being triggered from. So you'll probably need to go back a layer to get the [Id] value of the record that was being added. It might work if you use:

"component_master_id": "<<[_THISROW-1].[id]>>",

 https://help.appsheet.com/en/articles/961746-template-start-expressions

This video also really helped me:

https://youtu.be/Pok9v1YpND8?t=1485

I am on about the 20th run through of that video lol.

I gave the [THISROW-1].[id] a shot still no luck.

According to the doc on the start expression anything evaluated between the start and end is evaluated in the context of the records returned by the start expression so i think [id] should be right??

 

"By contrast, the expressions between <<Start>> and <<End>>, other than the Start Expressions, are evaluated in the context of each child record. In our example, since the Start Expression refers to Order Details records, the expressions between <<Start>> and <<End>> are evaluated in the context of a child Order Details record. The expressions between <<Start>> and <<End>> normally refer to the columns of the Order Details record."

Where is the "4379e5e7" value located? Is it in a column in the maintenance_events table or the components_master table? Also, before you rewatch the video a 21st time, you might want to rewrite the Filter() expression as a Select() expression. I've had some weird luck with Filter() and Lookup() expressions so I usually just use Select().

Something like:

SELECT(components_master[id], [pump_type] = [_THISROW].[asset_id].[tri_or_quint])

If the "4379e5e7" value is located in the maintenance_events table then this should work:

"maintenance_event_id": "<<[_THISROW].[id]>>",
"component_master_id": "<<[_THISROW-1].[id]>>", etc...

 

If the "4379e5e7" value is located in the components_master table then this should work:

"maintenance_event_id": "<<[_THISROW].[id]>>",
"component_master_id": "<<[id]>>", etc...

 

If neither of those work please send a screenshot of the column structure of the table where the "4379e5e7" value is located

oh wait, is the components_master a column in the maintenance_events table? Could you also send a screenshot of the column structure of the table that you want to create the new records in?

"4379e5e7"  is a hard id value from the components_master table. I have tried a select in the start statement as well with the same results.

I'll add screenshots of the schema of the three relevant tables to the original post they have a lot of columns so it is hard to get a screenshot of the whole configuration screen.

Top Labels in this Space