Trigger workflow from menu/view (not from within table row)

Is there a way to create a view that is essentially only a button that triggers a workflow? (nb. so a button in the menu, not in any row detail view)

I’d like users to have a main menu item that triggers (via post request) an appsscripts in the gDrive sheet. ie. “refresh my data”. This appsscript will update the data in the gDrive sheet from a back end database.

nb. since the backend database is updated every minute, scheduling the appsscript (ie. daily) is not a usefull solution.

Solved Solved
0 5 380
1 ACCEPTED SOLUTION

@Derk-Jan_Woltjer
In some extent, yes it’s possible. However, the user needs to SYNC the app again to see refreshed data from the back-end provided your script is refreshing the data in the back-end.

To accomplish this:

  • Set a Menu/Home Menu table within your back-end and a DateTime column at the end of this table.
  • Set a Behavior Action for this Menu Table:
    • Do this > Data: set the values of some columns in this row
    • Set these columns > DateTime | NOW()
    • Prominence > Do not display
    • Only if this condition is true > [KeyColumnName] = “The_ID_of_Refresh_Data_Menu_Item”
  • Set a Deck View for your Menu/Home Menu.
  • For the Row selected property of this View, assign the above behavior action
  • Set a Webhook Workflow Rule which will work with UPDATES_ONLY

When the user clicks on the Deck View item i.e. Refresh My Data, it will initially trigger the action and record a NOW() value to the DateTime column of the table, and then the workflow rule will be triggered which will make HTTP POST request to your appscript code.

To achieve this; you need to wrap your original code inside a doPost(e) event and then deploy that code as webapp which should run as you and for anyone, even anonymous.

And maybe remind you again; provided your Google Apps Script is updating back-end data, the user SHALL EXPLICITLY SYNC the app to see any updated data.

View solution in original post

5 REPLIES 5

Steve
Platinum 4
Platinum 4

Nope.

@Derk-Jan_Woltjer
In some extent, yes it’s possible. However, the user needs to SYNC the app again to see refreshed data from the back-end provided your script is refreshing the data in the back-end.

To accomplish this:

  • Set a Menu/Home Menu table within your back-end and a DateTime column at the end of this table.
  • Set a Behavior Action for this Menu Table:
    • Do this > Data: set the values of some columns in this row
    • Set these columns > DateTime | NOW()
    • Prominence > Do not display
    • Only if this condition is true > [KeyColumnName] = “The_ID_of_Refresh_Data_Menu_Item”
  • Set a Deck View for your Menu/Home Menu.
  • For the Row selected property of this View, assign the above behavior action
  • Set a Webhook Workflow Rule which will work with UPDATES_ONLY

When the user clicks on the Deck View item i.e. Refresh My Data, it will initially trigger the action and record a NOW() value to the DateTime column of the table, and then the workflow rule will be triggered which will make HTTP POST request to your appscript code.

To achieve this; you need to wrap your original code inside a doPost(e) event and then deploy that code as webapp which should run as you and for anyone, even anonymous.

And maybe remind you again; provided your Google Apps Script is updating back-end data, the user SHALL EXPLICITLY SYNC the app to see any updated data.

@LeventK, thank you, excellent description. It works!

note. One “issue” I ran into: it’s important to set the format of the DateTime column explicitly to datetime. Setting it to date results in only being able to trigger the action once a day, since the date value that is beging recorded by the NOW() action is not changing if run on the same day. And if the value does not change, the action will not be triggered.

You’re welcome @Derk-Jan_Woltjer . Glad to hear that it’s working, thanks for your feedback on this.

That’s correct but you already can’t record a NOW() value to a Date column, it shall be TODAY(). In fact that’s the reason why I have said a “DateTime” column instead of a “Date” column. Up-to a certain extent, a Date type column with a TODAY() value might work as well (though never tried this way as I always find using a Datetime column a more robust solution) provided you set below conditional rule for the workflow:

AND(
	ISNOTBLANK([Date]),
	OR(
		[_THISROW_BEFORE].[Date] = [_THISROW_AFTER].[Date],
		NOT(
			[_THISROW_BEFORE].[Date] = [_THISROW_AFTER].[Date]
		)
	)
)

So, to clarify things. As @Steve is pointing out, there is no way to add any kind of action into the existing AppSheet side menu. You can only navigate to views from there.

As @LeventK points out there are other ways to accomplish the behavior. Many developers create a view (A Deck View or a Gallery View) that behaves as an App Menu. You can add to that view “menu items” (i.e. rows) that act as menu buttons and then attach basically any supported behavior you wish.

Top Labels in this Space