Delete data button - target a specific table to delete from the home page?

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

We would like to create a button or link residing on the home page that targets a specific table to delete the entirety of its contents.

Is this possible?

Thanks,

Chris

Photo of Chris

Chris

  • 4,430 Points 4k badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 59,768 Points 50k badge 2x thumb
Yes, its possible - Maybe.  Will the user pushing this button has Admin access?  I seem to recall that the API to Purge requires Admin level access.
Photo of Josiah

Josiah

  • 0 Points
API_PurgeRecords does NOT require Admin access, but the user does need to be able to delete records. And yes, this is pretty trivial to do if you're familiar with using the Quickbase APIs. https://www.quickbase.com/api-guide/purgerecords.html
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 59,768 Points 50k badge 2x thumb
Chris, Let me know where you want to land the user after they push the button and I can help you with the formula. Josiah is correct that the users do not need admin access.
Photo of Chris

Chris

  • 4,430 Points 4k badge 2x thumb
Hi Mark, Sorry to revisit this so late in the game. The user would need to land on that purged table's dashboard to confirm the purge.

Thanks,
Christopher
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 59,768 Points 50k badge 2x thumb
I would suggest

var text URLONE = urlroot() & "db/" & [_DBID of the table to be purged] & "?act=API_PurgeRecords;

var text URLTWO = urlroot() & "db/" & [_DBID of the table to be purged] & "?a=td";

$URLONE

& "&rdr=" & URLTWO;

Be sure of that DBID so you do not purge the wrong table. :)  This is no "are you sure" step.
Photo of Chris

Chris

  • 4,430 Points 4k badge 2x thumb
Hi Mark, This worked great. I added the apptoken to the query string. However, I'm not redirected but stay in the XML page that tells you the purge was successful.
Photo of Chris

Chris

  • 4,430 Points 4k badge 2x thumb
I made the button accessible only to the Administrator role. Thank you.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 59,768 Points 50k badge 2x thumb
I had errors in my formula


I would suggest

var text URLONE = urlroot() & "db/" & [_DBID of the table to be purged] & "?act=API_PurgeRecords";

var text URLTWO = urlroot() & "db/" & [_DBID of the table to be purged] & "?a=td";

$URLONE

& "&rdr=" & urlencode($URLTWO);
Photo of Chris

Chris

  • 4,430 Points 4k badge 2x thumb
Thank you for the update. It works just fine. :)