Automatic Toggle Trigger 💡

Hola a todos!

Testing an idea to get something automatic able to fire any event based on time, I could create something that I called “Automatic Toggle Trigger” (if you have a better name, go ahead… I can change it!).

The idea is simple and has 5 components (columns):

image

  • Time: It’s the current time generated by Glide using Now() function. Due to Glide’s heartbeat is set to 10 sec, our triggers can’t be faster than 10 sec unfortunately.
  • SECTIME: The seconds of the current day
  • Enable Trigger: The switch that enables/disables your toggle
  • Delta: It’s the frecuency to change status (On ← → Off). This should be a multiple of 10 due to Glide’s heartbeat is based on 10 sec
  • Status: The value/state of your toggle using a numeric format (0= Off / 1= On)

The main logic is carried out by the Status Column (Math) using Mod() and Trunc() functions, there is no rocket science behind it! :slightly_smiling_face:

image

How does it work?

  1. Just set a valid value (multiple of 10 sec) to Delta column and later, enable (ON) its “Enable Trigger” associated .
  2. After this, you will see how its Status toggles from 0<–>1 (False <–> True) every “Delta” sec

What is the use of it or what is the advantage??
You could use this for:

  • Firing a webhook periodically and get the weather conditions or the song name playing on internet radio (API calls)
  • Showing a message or alert on your APP based on a period of time
  • Avoiding using a Google script ruled by a timed trigger

Anyway, you can see a video to understand better the idea here:

Or test it on this APP and copy the logic: https://toggle-trigger.glideapp.io/

I hope @Krivo can understand this idea better now!

Saludos!!

10 Likes

This is great. Thanks for sharing.

1 Like

Thank you for sharing! I definitely have some use cases for this.

1 Like

I can see how this could be used to periodically refresh a code column, but I can’t for the life of me see how this could be used to fire a webhook on a schedule. What am I missing? :thinking:

3 Likes

Hola @Darren_Murphy

You might have a JS code to have the weather between 2 cities, if Status is 1, shows data associated to Maracay (VE) else shows Houston (US) weather using an API call.
Of course, this code is not for Webhook actions per se, it’s just a simple example how to use this idea playing with API calls.

Feliz dĂ­a!

1 Like

Interesting! Novel idea—I like it. Nice hacky workaround until Glide provides native time based triggers.

3 Likes

@gvalero very much appreciated :+1:

yes, I get that bit.

Okay, that’s the part I needed clarification on. Thanks :slight_smile:

2 Likes

Hello everyone, does anyone here have any idea how to use this to be able to update the data in a column automatically? I have a column with the product availability “Inventory” and the next column with the weekly availability “Default inventory”. I am trying to automatically change the data in “Inventory” every Monday by copying those present from the “Default inventory” column.
Thanks

Hola @BDN_Jacopo_Chiapello

While I find out a right answer for your request I need to know something before:
Do you want to update your inventory automatically not matter your APP is running?

Unfortunately, this trick works only when APP is running on any device, there is no way to trigger it on Glide side (server) in background automatically so far.

Saludos

Both the solution are ok, if it’s necessary i can go on app in specific time to start one action whit the button but i need to set the action to do the copy action from column “Default inventory” in “Inventory” automatically when i Press the button.

What do you mean whit “APP Is running in any device”? Can be the action started automatically when any user logs in? (not the admin)
I don’t need to have the updated inventory at the exact moment. The important things Is that It is updated when the First user enters.

Ok, I think you can make it simpler, You might use Math function Weekday() and parse if the current week day is Monday to activate your button. In your case, your magic number is 2 (Monday)

image

Later, you can play with visibility conditions to show/hide your new Update Inventory button at any time every Monday when you load your APP and press your update action.

Saludos!

The question is not how to check the correct day but how can i update the inventory from column B to column A.
I have Column B whit different quantity per product.
I need to copy and paste all this quantity from column B to column A when i press the action button.

When viewing the details of an item, all you need is a button with a Set Column action that will take the default column value and overwrite the inventory column value. I think @gvalero was trying to provide some logic to help control when that button is visible.

2 Likes

Yes sure but i Need to Copy more Rows whit only One button.
Whit set column values i can copy only one row at a time

Is this in a Google Sheet or a Glide Table? If it’s a google sheet, I’d probably just set up a timed trigger that will iterate through each row in the table and reset once a week. If this is a glide table, then you may have to utilize the glide api and something like Integromat/Make or Zapier to iterate through a list of RowID’s and update the inventory column

I can’t think of an easy way…or any way…to perform a set column action on multiple rows from a single action strickly within glide. I think an action would have to occur whenever the first user views a specific item. Then store a date and time when that reset occurred, so you knew when to reset it the next week when a user views an item for the first time.

Unfortunately it is on glide tables. Following your logic one thing came to my mind, If I create an action that every week I manually click as administrator and it clears an entire “switch” column and then I insert a new action with condition in my flow that IF the first user of the new cycle find the empty Switch column copy the value from “Default Inventory” to “Inventory”? I think it might work but the question is how do I clean the values ​​of a column in all the rows of the sheet? Do we have the same previous problem or is it feasible?

Now I am understating your use case, there was something not clear in the beginning but no problem.

I know the problem you are facing (I have had it since months ago), you want to update your inventory using several rows at the same time but the Set Column action only works with a simple relation or with the current row (This item).

If a Set Column action could work with a multiple relation we’d have the solution very fast/simple but it isn’t possible so far. Your case is similar to the shopping cart system when a user has ended an order, we need to clear that shopping cart and start process over but Glide doesn’t allow a multiple relation in a Set Column or Increment Number action and we have to implement other workarounds… a tragedy to me! :face_with_thermometer:

Your plan B (what I use so far) is to use a GS script to get it but working with Glide Tables (GT) the case gets worse.

Sorry for this bad news.

Saludos.

1 Like

Yes, it’s for shopping cart.
I found a solution, for my specific case it’s ok because i only have 32 items.
Only one compromise requested, you have to create a inline list and click on the products one by one. You can use the function set column values in “Switch” columns. I set 1 on this click. Click on all items one time to set 1 for all products.
Now the system Is activated, all time that the first user of the day click on one product active one function that verify if “Switch” column Is 1 and if YES it copy “Default Inventory” value in “Inventory” and set 0 in “Switch”.
I set the Switch column because i use the it to Hide/Display products that are restored. When inline list is empty the flow is ready.

One time a week you only have to click on all products one at a time to restore the flow.

Whit small inventory i think this is a good solution.

Sorry for bad explanation, i tried to do the best.
If you want i can share the demo to understand better the flow.

It is a more complete version of a shopping “template” provided for free by Jeff a few weeks ago.

2 Likes

Ah but @Jeff_Hager has a better trick to “clear/hide” quantities in these cases (specially for shopping cart). Here we discussed this topic: https://community.glideapps.com/t/reset-multiple-rows-at-once/

Maybe it can help you.

Chao

1 Like