Webhook add row copying multiple records

Hoping for a tip on why this bot is copying in multiple rows, instead of copying 1 row for each employee with Shift Status=“On Shift”, it is copy the number of employees that are on shift and then using that number as a multiplier and adding a row for each employee.

So if 3 employees are on shift at the event time the Bot creates 3 rows for each employee. How do i limit the rows per employee to 1?



my json expression is:

{
"Action": "Add",
"Properties": {
   "Locale": "en-US",
   "Timezone": "Singapore Standard Time"
},
"Rows": [
<<START: SELECT(Employees[Employee],[Shift Status]="On Shift")>>
{
"Benefits Key": "<<UNIQUEID()>>",
"Benefit Employee": "<<[_THISROW-1].[Employee]>>",
"Benefit Type": "Meals allowance",
"Beneficial Date": "<<TODAY()>>",
"Beneficial Amount": "20000"
}
<<End>>
]
}

3 Likes

What is happening is that the scheduled event is “For Each Row In Table”, so if there are 3 rows that match the condition. There are 3 Bot execution, one for every for, with that row in context of the execution. Each of them calls to the webhook.

There are a few things that you can do.

  1. As Marc mentions above make the webhook call just for the row in context of the for each Bot execution.
  2. Instead of using a web hook, just use a data-action to add a row to another table. Its simpler than a webhook call.
  3. Disable the “For Each Row In Table”, this will cause the event to be a generic trigger, then your current webhook expression would do the job for all rows.

I would go with option 2.

3 Likes

Thanks for the tips guys,

In my use case there will be about 30 rows copies taking place, i went with the server side (webhook) as apposed to the client side (action) just loosely based on the number being around 30 or more. Would you still recommend option 2 considering this?

Actions can be used both in the client and in the server. If you have a Data Action step it will execute the action on the server side. That would be better than using a webhook.

2 Likes

To clarify, all Actions used in Automation - Data Change and Scheduled - run on the server side. Is that an accurate assessment?

Yes, just as they did in workflows and reports.

Yes!

1 Like

In the end what is the solution, do you have screenshots?