Appsheet Webhook Running Multiple Times

Good day,

Utilizing the Scheduled Reports function of executing a task on a specific day at a specific time, (say Wednesday @ 6:45 AM) It executes a webhook that Dispatches jobs from a Customer table based on if they’re a recurring customer that have jobs the same day every week.

It is working as intended, however the webhook looks like it is running multiple times! (Usually 3-4 times) I’ve looked at the logs and on average it can take over 600 seconds to go through the whole Customer table, which is beyond the max limit of 300 second for the timeout (not sure if this is an issue). “Run asynchronously?” is OFF.


2X_a_a4c8b0c2cd9fa7848d4ff52ee73e5131af8e4938.png

I’m guessing this is Total time to go through Customer Table? (Executes 3 times)

2X_5_56402dfe2d01041fceca865e06f288094b7e3111.png

2X_5_56e2def8ebab226b6ca614151158a96707df8f4d.png

2X_b_b86c40d95b4800c861f2ff107846115c9d5dddc3.png

This is the time it took to execute the actual webhook? (Add Row)

2X_a_aaef0e2c8e5be4b1ac6dc0a38a766ef56498a3ce.png

Is there anyway to prevent it from running multiple times or an explanation as to why it is behaving this way?

1 Like

Chiming in @Phil. Phil can you check this issue at your convenience?

Yes, the long running time of your Report is very likely the cause of the problem.

I have just added an article that explains how Report scheduling and retry works. See https://help.appsheet.com/en/articles/3188644-report-scheduling-and-retry

3 Likes

Is there a way that I can edit the ‘Retry Report on Timeout’ ?
Perhaps we could increase the timeout period manually or remove it completely?

The webhook does run it’s course all the way through and creates all the jobs, would it make sense that it only retries when one isn’t already running with the same name?

I’m not sure how I can mitigate this problem on my end after reading the article, it just confirmed what my problem was. Our customer list is only going to grow and increase the processing time.

Any suggestions?

Can you describe what you are doing in more detail?

I will also be discussing this issue with Praveen our CEO.
To this point we have treated Reports (scheduled Rules) as relatively short lived actions with fixed timeout periods and fixed retry schedules.

We may need to accommodate longer lived actions with user specified timeouts and retry schedules. I don’t want to raise expectations too much, but we will discuss the matter.

1 Like

We are essential automatically creating a dispatch of jobs for a service company which have clients that receive certain services on a fixed schedule (Ex. One service a Week every Monday). We do this by leveraging the Reports periodic schedule which you can see in the Screenshots I sent.

The report goes through our ‘Customer’ table and checks for three main indicators to determine whether it should create a dispatched job on the ‘Jobs’ table. Say it was Monday.We would check for the: AND(Service Type = Weekly, Account Status = Active, and Service Day = Monday) The report runs at 6:45AM CST every day.

If all three of these are TRUE, the webhook will Add a New Row to the Jobs table (which acts as a dispatch for workers and used as a logbook at the same time).

So, the Scheduled Report will go through our 450-500 row Customer table checking for these 3 variables on each customer (row), then it will trigger the webhook which adds a new dispatch on the Jobs table for the assigned employee to complete.

The Report continues to Retry every 4 minutes until the original (1st try of the) Report completes it’s Cycle. So I’ll essential have a giant list of dispatches for that day and will need to manually go in and delete over 400 duplicates every day at the moment. Which almost defeats the purpose of having it automated in the first place.
_
On a side note, if these Report’s are supposed to be timing out, shouldn’t they stop running?
Why does it continue to run all the way through to end of our Customer list either way?
Does the Report wait for the webhook to complete before moving onto reading the next row? Perhaps there is a way to have it continue running through the report and just have the Webhooks run at the same time (asynchronously?)

Going to try the Run Asynchronously feature actually now that I think of it.
Should AppSheet run this webhook asynchronously (in the background) and let the rule return immediately?

Yes, if you specify “Run Asynchronously” the webhook will be invoked, it will run asynchronously, and the call will return immediately. That may greatly help performance in your case.

I wonder if you could use the REST API to make the adds to the Jobs table even more efficient? The REST API allows you to add an entire set of rows in a single request. That is vastly more efficient than adding rows one at a time.

To add multiple rows at a time, you define a JSON template that contains a << Start >> expression than selects the rows you wish to add. All of the selected rows end up in the JSON body that is sent to the single REST API “Add” call.

You can include the row selection logic in the << Start >> expression within the JSON body. But, it is often easier to create a Slice that contains the row selection logic. This makes it easier to verify that the Slice is return the expected rows. You then use the Slice in the << Start >> expression within the JSON template.

You can use both techniques at the same time. You can use a single REST API “Add” that specifies “Run Asynchronously”.

2 Likes

So I would need to change the Report from evaluating on each row to the entire table.

This is what I currently have for my JSON body template:

{
   "Action": "Add",
   "Properties": {
      "Locale": "en-US",
      "Location": "47.623098, -122.330184",
      "Timezone": "Pacific Standard Time",
   },
   "Rows": [
      {
         "ID": "<<UNIQUEID()>>",
         "Job Status": "Incomplete",
         "Customer ID": "<<[ID]>>",
         "Assigned Scooper": "<<[Scooper Assigned]>>"
      }
   ]

Is that what It should be to accomplish what you said?

{
   "Action": "Add",
   "Properties": {
      "Locale": "en-US",
      "Location": "47.623098, -122.330184",
      "Timezone": "Pacific Standard Time",
   },
   "Rows": [
    <<Start: SELECT([ID], AND([Account Status] = "Active", [Service Day] = "Monday", OR([Service Type] = "Weekly Yard",[Service Type] = "Priority Weekly")))>>
      {
         "ID": "<<UNIQUEID()>>",
         "Job Status": "Incomplete",
         "Customer ID": "<<[ID]>>",
         "Assigned Scooper": "<<[Scooper Assigned]>>"
      }
      <<End>>
   ]
}

Your new template looks right except I don’t see the closing >> tag after the Start expression.
(That might be because of how this website displays >> tags.)

You should see a huge performance improvement if you are adding many rows.

1 Like

Will implement this for Friday and get back to you, thank you for helping me find an alternative solution.

1 Like

Looks like it’s working as Intended, thank you! Pretty much instant now.

1 Like

Thanks for the update. Really glad to hear that it is working!