App Requires a Delay

I have an App where the operator selects products and these products are then brought into an invoice. The screens are attached.
The active button is the one labelled "Select Item for Invoice".
After making the selections, the code works fine if I press "Finish" first then press "Select Items for Invoice".
But if I make the selections and press "Select Items for Invoice", it then adds the previous selections.
Any advice would be appreciated.

Hey @mdsmith1!

Would you mind posting screenshots of how you have your "Select Item for Invoice" and "Finish" buttons configured, along with any of the queries they reference?

I am attaching the list of actions under the "Select Item for Invoice".

Most of the actions are self explanatory but I wanted to comment on "Insert TabtoTab". This one looks for check marks in the Products Table and inserts certain fields into the Invoice Table. The problem is that it inserts the rows that were made in the previous selection.

If I click the "Finish" button first, then it works properly. The code under the "Finish" button is the same as the "Save Changes" code under the "Insert ....... " button.

If they share the same code it sounds like you might be able to solve it by ensuring the queries fire in the correct order, using either success handlers or await (similar idea to this post). Do you know the exact order the queries need to run in? And which queries can run concurrently?

I have tried using "await" to get the code to complete its work but I have not been successful. In the attached graphic I have "UpdateProductsEX3b" which is supposed to copy "XXXXX" into "EXTRA3" where "Check01" = 1. If 2 rows have "Check01" = 1, it only copies to one of the 2 rows. I have "await" statements in the code to slow it down.
If I run the code stand alone, it works fine.

I see, can you post a screenshot of the query you're using to set Check01 to 1? And also one of where you're using await?

Here are the screen shots:

  1. Screen for checking in the left column for the products you want to add to the Invoice. Check01 has a value of 0 if unchecked and 1 in checked.
  2. This code is to give a value of XXXXX to Extra3 where check01 = 1. This code works fine if I fire it stand alone in development mode but it does not fire when run with the button "Select Items for Invoice".
  3. The is the Await code following the code in (2).
    There is no sign of any of the code in (2) actually working.

Thanks for that context!

It looks like the UpdProductsEx3b query is checking against the value of the Check01 column as it exists in your database. If the user selects boxes in the Check01 column of the table in your frontend you might have to push those changes to the database before the UpdProductsEx3b will work properly.

It sounds like the "Finish" button you mentioned in your original post does just that which is why clicking it first works, so you could have a JS query that does something like

await FINISH_QUERY.trigger();
await ProductEx3b.trigger();

replacing FINISH_QUERY with whatever query attached to the "Finish" button is updating your DB.

Can you let me know if that helps?

Note: Putting await in front of a trigger call doesn't change the behavior of the query you're awaiting, it just tells the script you're running to wait until the query is done.

I already had the Save code into my previous code. I have tracked what is happening to my table and the Check marks (Check01 = 1) are saving up to the Server OK.

But the code to mark EXTRA3 with XXXXX where Check01 = 1 does not work in the production environment.

If I run it stand alone in the development environment, it works fine.

After I run the code to mark EXTRA3 with XXXXX, I run the AWAIT code.

I am showing you the details in the attached screen captures.