Can you create a button in a report that would execute an automation?

  • 0
  • 1
  • Question
  • Updated 3 months ago
  • Answered
The Automation deletes records that don't have any Related Team Memeber Assigned. I want the user have the ability to execute the automation with a press of a button if possible. Thank You!
Photo of Maulik Patel

Maulik Patel

  • 70 Points

Posted 3 months ago

  • 0
  • 1
Photo of Alex Wilkinson

Alex Wilkinson

  • 1,146 Points 1k badge 2x thumb
My usual practice in circumstances like yours is to ...
  1. Create a checkbox field for the to-be-deleted records. It would be a formula-checkbox, in your case, where the formula evaluates to true if Nz([Related Team Member],0)=0. That formula works whether or not Related Team Member is set to treat nulls as 0 in formulas. Sometimes, I use a plain checkbox, not a formula checkbox, to designate the to-be-deleted records. In particular, I use a plain checkbox when a user who lack permission to delete wants an automation or an admin to do so.
  2. Create a report that lists all the records on which the to-be-deleted checkbox is checked. This enables you to see what's happening, and to delete a batch if the automation is not working.
  3. In the automation, use the to-be-deleted checkbox to filter the records that the automation should delete. If you don't expect more than 1000 deletions per day, it may be desirable to use a scheduled deletion. Alternatively, you could trigger the automation whenever a record is modified and the to-be-deleted checkbox is checked. However, beware that if more than a 1000 records get modified as to-be-deleted at once, e.g., by a mass import or by some other automation, then you may hit the 1000 limit, even though your automation triggers on one record at a time.
  4. Thus, if needed, you may have to devise several automations, each of which uses, say, modular arithmetic on Record ID# to guarantee that at most 1000 of the deletable records will in fact be deleted by any one automation in the group.
(Edited)
Photo of Jason

Jason

  • 1,406 Points 1k badge 2x thumb
Your question makes me think the following -
1 - why are there so many records missing that data
2 - why am I giving a user the ability to run a mass delete?, what if I need those record still?
3 - we really need the mass delete?
I would ask myself these and if the final answer is mass delete I take the user out of the equation. I would avoid the whole button and checkbox formula and set the automation to delete records where the field Related Team Member Assigned is blank and put it on a schedule. Then you can even put the automation on a daily schedule or if more time is needed to assign someone a weekly schedule.

But if you want a button to put this on a person to execute the action I would create a User and a time/date field. Have the button populate those fields with the current user logged in taking that action and the date of the action. The automation could then look for that field to change in any record and execute the delete records where the field Related Team Member Assigned is blank. Assuming that the record containing the data isn't one being deleted you now can have a record of who when and how often that button is used.
Now if you like that idea you can take it one step further if you want to track the data safely. Create a table with a user field. Have the button add a record to that table with the user name (date created covers the date/time) and then the automation can trigger off the record being added.Now you have a complete record of who and when logged and not where the users can delete that data.

One note - if it is over 500 records the deletion will take a few minutes to run but that normally isn't an issue on deletions. A faster method to delete can be done with a webhook using the
API_PurgeRecords and point to a report that shows only the records that the field Related Team Member Assigned is blank. Also you can use the same button.

As you can see there are a lot of ways to do this.