I’d like to make a Glide app that lets the user purchase a number of credits and then use a credit to order a to-go meal.
I can almost implement everything I needed with the current feature set (and some Google Apps Scripts) but there’s still a deal-breaker: even with Pro refresh, the 1 minute or longer delay between a script converting an order into credits and updating the app data with those credits is too long for this purpose. Similarly the remaining number of credits won’t decrement until a minute after you spend one.
Because the updated data I need is always ready a few seconds after submitting a form or an order, I suggest that after actions like that, a pro app with data refresh enabled will automatically refresh maybe 3 times in the next 9 seconds before going back to the standard interval.
I had thought of that myself as I do use a lot of scripts for calculations, which in some cases can take a bit of time to fully calc. Why don’t you put this in as a feature request. https://features.staging.glideapp.io/
Done! Thanks for the link. Looks like suggestions don’t automatically show up in the main list (moderated I guess?) but FYI I gave the request the same title as my post here.
Could you tell us what you’re doing in Google Sheets that you can’t do in Glide right now? We want to make more Glide powerful enough that going back to Google Sheets isn’t necessary anymore.
Sure! It boils down to wanting to be able to have users purchase and use consumables of some kind. To-go meal credits in my case (like MealPal), but would be useful for things like personal training sessions as well.
I think my dream solution with Glide would be to have credits or virtual currency be a special kind of thing that gets managed by the Glide system. Like having an “App:Credits” sheet that lists one or more types of currency for each app user. A Stripe purchase and maybe other actions could add X amount to currency Y for the current user. Components could be shown or hidden based on currency thresholds. And form submissions could automatically deduct X amount from a given currency.
That said, here are the particulars of what I was using Apps Script for:
I wanted to give users 1 credit when they signed up, for testing. There seems to be no way to submit a new user form and supply an implicit default value. I tried setting up Single Value and Template columns and sending those as implicit column values, but those seem to not work correctly until after the user row is set up. So one of my script actions is to look for new user rows and fill them in with some default values. Just having a hidden default value component would solve that.
When the user submits a form to order the meal of the day it adds a new row to an Orders sheet. I need to:
Mark the user as having ordered for the day.
Subtract 1 credit from the user’s balance.
Make sure the order isn’t a duplicate since it takes a while for the above two changes to propagate back to the app and the user could submit the form a second time.
Here are some other things I was planning to do.
I would have a per-user admin flag that allows the chef to manage upcoming meals (easily done) and see how many orders were placed for the meal-of-the-day (easy using a formula).
Admin mode would also allow a server to see a list of all the orders and check off the ones that have been picked up (easy I think).
I would have a “cron” script that goes through once a day and resets the “order placed” flags so the user can order again the next day and it would copy the info for the next available meal to a “current meal” slot. It would probably also move all of the day’s orders to a permanent log on a separate sheet. This one is custom enough to where sticking with a script is probably appropriate.
I have a pretty basic Currency sample in https://concepts.glideapp.io/. There is some other stuff in the sheets where I was attempting to make it more advance, but got stuck on a couple things. @Robert_Petitto has done the same thing to a more advanced level, but take a look at my app, make a copy, and see if any of it would work for you. I think you could make purchases apply credits to a user, and the any form responses for a meal purchase would subtract a credit via a rollup and math column. Everything would be lag free except for the minute or so for the purchased credits to appear in a persons account. The rest would be instant and you could use the math column value to control visibility of any components.