hi, does anyone have an example of how to delete the data from a table of a dating application, for example, I have an appointment for the day 01/03/2022
In March at 2:00 p.m., how can that data be deleted? If the appointment has already passed that day, it is no longer necessary to have it on the sheet. How can it be deleted automatically?
Iāve considered doing something like this in my app to clean up old data.
What I would do is create an IF column in the table with the dates. The IF column would check if the date is prior to Now. If it is, then return ātrueā for a value.
Then I would pick a section of the app that is viewed often by users. In the table that drives that part of the app, I would first create a template column with the word ātrueā. Then I would create a single relation that links the template column to the IF column in whichever table contains the dates.
Now when a user clicks on a list item, for example, you can turn the action into a custom action that will first delete the dated row through the single relation, followed by going to the detail screen of the selected item.
The user will have no idea that they are the ones deleting the old rows. Itās not an automated process, but the more that a person uses the app, the more the old records will be deleted.
So, the trick is really to delete the row through a single relation, but make sure that the single relation only relates to rows with dates that have already passed.
I kind of do something similar in my calculator app. I have a rolling history table that keeps a history of the last 20 calculations that were done by the user. The table only ever has 20 rows. No more, no less. I have some logic in the history table that checks timestamps and ultimately marks the next row that should be updated. Then the calculator table has a single relation that links to only that row in the history table thatās marked as next, and that is the row that is updated when the user presses the equal button. Itās a little more complicated than you would need, but I think if you can mark the rows with some IF logic as the ones that need to be deleted, then a single relation to that marked row and a delete action that deletes through that relation should work for you.
Thatās not possible without using something external to Glide.
But, have you read Jeffs response above
Thatās a really clever approach, and could easily be extended to hide the expired rows from view using filtering conditions. So the end result is that data would automatically be hidden from view at the appropriate time, and would eventually be permanently deleted.
@Jeff_Hager I decided to give this a try in my Custom Forms demo app. Because that one gets linked to a lot, it tends to accumulate quite a bit of āgarbage dataā as folks try it out. I used to periodically clean out junk rows, and then a few months ago I got sick of doing that, so I implemented a system where the original half dozen or so rows were kept āstickyā, and any new ones added would disappear after a day. That worked fine, but it didnāt stop the accumulation of garbage data - it just swept it under the carpet.
So I just quickly applied the technique you described here, and it seems to work like a charm. Iāve attached it to the Save new animal button, so now every time somebody creates a new record, an old one gets nuked.
I can foresee myself using this technique in quite a few apps moving forwards
Awesome! Glad to hear it works. Why bother with scripting, or outside integrations when the user can unknowingly do all the work.
Iām planning to do something similar to clear out records that are over a year old in one of my tables. Or at least archive the old records into a separate table thatās not used for anything and doesnāt contain any additional computed columns. I think this would help with some speed issues I have with a table thatās been accumulating data for almost 3 years now, and is very heavy with computed columns.
Hi,I have been looking at your application I have seen that in actions you put it to delete the column but I see that it does not delete it. The rows of the year 2021 continue
I was wondering, since you two seem to be developers in your day jobs: do developers also implement these types of āhacksā in their code? I ask because though I find your workaround really smart Jeff, I think it would pain me to do it I donāt know why, but I really dislike workarounds in general. Not practically, but conceptually.
Anyway, really nice technique to outsource clearing garbage data : )
Maybe you donāt understand what it does.
It doesnāt delete any columns, it just deletes a single row - the first matching row that forms the single relation.
If you add an āanimalā, you will notice that the total number of rows in the Animals table doesnāt change. Thatās because every time one is added, one is also deleted.
Hehe, programming is all about hacks and workarounds. Anything to make it work and get the job doneā¦and still get a paycheck.
I mean, for something like this particular use case at my job, I would have access to run something like a scheduled nightly job to clean up the tables. Our whole system is internally built, so I have access to all the code, mainframe, servers, data, etc. Plus something, like calling a function that loops through and processes multiple rows of data, is very trivial.
Glide is different in that we have to work within the boundaries of the Glide system. Glide doesnāt really have a headless side to it that we can use to run code without any user interaction. In here, everything depends on user interaction one way or another. The only option we have within the glide world would be to use Google scripts or a third party service like Integromat. Whether or not you call these outside services a workaround, is up to you. I guess the less I have to rely on outside services to get the job done, the less points of failure if one of them goes down for any reason. For that reason, I try to achieve whatever I can strictly within glide.
Yes, you could consider my solution in this thread, as a workaround. I agree and wouldnāt consider it normal to execute a function like this by exploiting another function called by a userās interaction with the app. A proper system would be an automated process that runs by itself. But Glide is meant to be a one size fits most solution thatās simple to use for most users. We donāt have access to all of the backend systems and code like a developer would. I think if they opened up that level of functionality, it would be much more confusing and overwhelming for the average user. I think Glide is trying to keep things simple, but some of us demand advanced functionality, so we have to come up with non-traditional methods to get it done.
At the end of the day, I think the word āworkaroundā can be interpreted loosely. Glide canāt reasonably build in all the functionality that can cover the thousands or millions of different use cases that everybody would have. Thatās what the code world is for. We need to work with what we have at our disposal.
If Iām getting the results I need, I donāt really care how itās achieved, as long as it works.
I donāt have a lot to add to what Jeff said, except to say that I violently agree with pretty much everything he did say.
I prefer to think of myself as a hacker rather than a professional developer. Iām mostly self-taught, and in general I know just enough to make myself really dangerous. Iām one of those guys that ārealā developers hate - a tinkerer. I like to get in there and mess around under the hood. Sometimes I know what Iām doing, but most of the time Iām just winging it - learning and experimenting and making it up as I go along. I often mess things up, and Iām really good at breaking things. But Iāve also gotten pretty good at cleaning up my own mess, and sometimes even the messes made by others
Although Iām not a professional developer by trade, Iāve been closely involved with software development (and developers) for more than 20 years. And there is one common trait that I think all really good developers share. Which is their ability to think outside the box and come up with creative solutions to difficult problems. In some sense, this is how progress is made. Many things we now accept as standard āfeaturesā probably began their lives as āsneaky workaroundsā
Thank you very much for your help as you said glide is limited and very good since many users would not know how to use the programming your idea has helped me and it is functional thanks and a hug from Spain
I first started ācodingā when I fiddled around in the early 90s with my parentsā PC, I would tinker with autoexec.bat and config.sys and create these really fun menus/journeys when the computer started. You cannot imagine how many sleepiness nights I spent fixing a computer that just would not boot anymore. Unlike you Darren, I never really became good at fixing my own mess, I got stuck on breaking things