Form inbetween action button and action being taken

Hi,

I have a a view that allows the user to select a date from the calender in a table

I then have an “Orders” table and view with an action button that will change any selected orders to the previously chosen date.

At the moment the user either goes to the menu to find the “select date to be changed to” view or another action button on the “Orders” table to choose the date and then hit the “change date button” to make the change.

Is there a way of the user just hitting “Change Date” and being asked to fill in a form (select the date), save and then the change being made?

Thanks

Phil

Hopefully I have a complete understanding this time around? :slight_smile:

AppSheet doesn’t have any kind of automated way to easily to do this but you can create your own process. Here is what I would do:

  1. Create a single row, two column (ID and Date) utility table used to simply hold the chosen date.
  2. Add a placeholder row to the table with some ID and date
  3. Create a Form view in the app for this new table with only the Date column. But, set the “Row Key” property to the ID of the row in 2). The form will ALWAYS load this one single row.
  4. Create your “Change Date” Action so it navigates the Form view above using the LINKTOFORM() target expression.
  5. Create a set of Actions:
    a) Action1 identifies the set of rows to be updated and calls Action 2
    b) Action2 applies the saved date from the utility table to the row to be updated
  6. Attach the Action set to the Form Saved behavior to the form created above.

So, the way this will work is a user will tap the “Change Date” action. They are taken to the “Change Date” form where they chose a date and then Save. The date is saved to the row in the utility table AND the attached Action set is executed. Action1 identifies the list of rows to be changed and each row is sent to Action2 one by one. Action2 retrieves the saved date and applies it to the row to be updated.

Each time a user taps the button the same row in the utility table is loaded and updated with the saved date. To prevent, a second user from interfering with a current update, you can add a third “Yes/No” column to the utility table used to “lock” the function until the updates are completed. The “Change Date” form can re-initialize this lock column to “true” on Save. the “Change Date” action can be disabled while the value is true so no other user can perform a “Change Date” function. Once the row updates are done, have Action3 set the value back to false.

I hope this helps!!

1 Like

Hi John,

You’re understood perfectly. I have done everything apart from the following

What sort of action is Action1 and 2 to identify the rows to be updated - I’m assuming that rows of orders have been selected before hitting the change date button so they are highlighted already before we go into the form.

Thanks

Phil

I was assuming there was some property on the rows you could use to identify them. If that was the case then this is what the Actions would be defined as:

  • Action1 if of type “execute an action on a set of rows”. I assume you have some way to identify the rows that need updated with the chosen date. You would apply the appropriate expression to do this in the “Referenced Rows” property of this action. you would also apply Action2 as the “Referenced Action”

  • Action2 is simply of type “set the values of some columns in this row”. In your case, you would update the rows’ Date column using an expression like ANY(SELECT(Utility Table[Saved Date], true)). Because the table only ever has a single row, you will always get that row back. ANY() will chose the first row and return the selected value - Saved Date.

For the user to chose the rows to be updated to some chosen date…

There isn’t a straight forward way to do this in AppSheet as a single activity/function. It would have to be a two-step process - either:
A) Chose the rows and “mark” them then chose the Date and apply to all the marked rows
OR
B) Chose the Date and save it then select the rows and apply the saved date to the rows.

Either way some portion of what i described above can be used.

In this situation I would ask myself, “How does the user chose the rows to be updated?” There must be some method to it and if so, “Can I automate the choosing method?”. If it can be automated then you would be back to my original assumption and the user just taps the “Update Date” action.

I can see how to attach an action to the form in “Event Actions” but only actions associated with the “change date” table with one row rather than an action for table “Orders” where data in the columns is changed.

I have the action to change the data but can’t make the link to have it fired once the date has been chosen and the form saved.

I have Option B up and running but it seems a bit clunky for the user to select the desired date then go to another view to implement it.

I was going to have the user select multiple orders and then select “change date” action.

This would ve a muliple action made up of

Action 1. change a column for selected orders in the table to “Run” therefore marking the orders to be changed in the future.
Action 2. take us to the form view where date is selcted and changed.

Action 3. Change the columns that had “Run” next to them in the orders table back to “” so they aren’t changed next time.

After that I can only attach actions for the date selector table.

Thanks

Phil

Hi,

Looks like I had my "Run " Column set to ref and had a spreadsheet formula in there too. I have the form view going to an “execute a sequence of actions” action that triggers the change date action attached to the “orders” table so it works now.

The Problem I have now is sequencing the actions to change a column status to “Run” in the orders table and back to “” aftwerwards so the action knows which rows to change the date on. At the moment have just manually put “Run” in the spreadsheet.

I have actions set up in sequence but nothing changes. If the user has to select orders and “mark” them up for a date change with another button/action then we are back in the same position as before in terms of the user executing a number of processses.

Thanks

Phil

HI have moved the action that turns the column to “run” to before the action to go to form view which makes sense and now works - but the action to turn back isn’t triggering after the changes.

UPDATE - I have created a workflow to change the “Run” back to “” triggered by an update in the spreadsheet. That has worked.

It sounds like you ironed out all of the wrinkles and have it working?

Just a little related knowledge…There are some unexpected things that happen in distributed systems like this.

For example, actions that run on the app will apply to the device as soon as they are run. So you might order your actions and all looks good in the app.

But then the associated updates are sent to the server. If one of those updates in the middle triggers a Workflow, that Workflow will process BEFORE the rest of the updates are applied on the server.

If the Workflow happens to change some of the same data as was updated on the device, then you can end up with competing processes and order of updates might be different than what you originally expected…if you weren’t already aware.

This is not a big deal if you are aware of it. It ends up being a matter of where to place the processing as you figured out by resetting the Run flag from within the Workflow!!

Thanks John, I’ll keep an eye out for that.

Having another problem though as shown in this post.

Cheers

phil