Forum Discussion

QuincyAdam1's avatar
QuincyAdam1
Qrew Trainee
7 years ago

How To Delete Record From Report Embedded On External Website

I have a delete button on my report, which works fine when I'm in QuickBase, but it will not work when the report is embedded on another website. My goal is to have the capability to delete a record from an external site, so if there's other suggestions how to do this, that's ultimately what I'm trying to achieve. 
Here's the code I'm using on the button:

////////// ATTEMPT #1: CODE I FOUND FROM FORUM
"javascript:if(confirm ('Are you sure you want to delete this record?')){location.assign( '/db/" & Dbid() & "?act=API_DeleteRecord&apptoken=xxxxxxxxx&rid=" & [Record ID#]& "&rdr=" & URLEncode("https://www.website.com") & "')}"
//////////
I have attempted hardcoding the root domain since it assumes you're in QB, but had not luck.

/////////// ATTEMPT #2: ANOTHER CODE I FOUND ON THE FORUMS
var text URL= URLRoot() & "db/" & Dbid() & "?act=API_DeleteRecord&rid=" & [Record ID#]
& "&apptoken= xxxxxxxxx";
"javascript: " &
"if ( confirm('Are you sure you want to permanently delete this record ? ') == true ){ "&
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"&
"}"
//////////

The 2nd attempt works the same, but does not have a redirect on it back to the page I'd like it to go back to.

1. Is there a way for a externally embedded report to delete a record and redirect back to the external page? If not,
2. Is there a better way of deleting records from an external Wordpress site? I looked into the API integrations, but haven't found any clear examples.

5 Replies

  • Quincy,

    Mark's method should be able to easily delete the record. However you need be aware of the fact that exposing usertoken on an external website is a security risk.

    If you external website is public, I would suggest you basically add a new record in some table known as delete requests capturing the record ID of the original record.

    Setup a webhook from that table to perform an API_DeleteRecord at the desired table.
    • KevinO_Boyle's avatar
      KevinO_Boyle
      Qrew Cadet
      Avi - would you create a new/unique usertoken in this instance only for the delete requests tables ?(is that the best way)
    • QuincyAdam1's avatar
      QuincyAdam1
      Qrew Trainee
      Thanks. I figured out the JS piece above. I just prepended the base URL onto /db like this:

      "javascript:if(confirm ('Are you sure you want to delete this record?')){location.assign( 'https://company.quickbase.com/db/"; & Dbid() & "?act=API_DeleteRecord&apptoken=xxxxxxxx&rid=" & [Record ID#]& "&rdr=" & URLEncode(�WEBSITE TO REDIRECT TO�) & "')}"

      I didn't assign a user token, since the report is public (or set to Everyone On The Internet). I need to do more reading up the link you had sent over, since I don't fully understand the difference between the different tokens and tickets.  

      In the event that I restrict it and I choose to use an API_DeleteRecord, what is the best method to fire the delete record. For example, do I just hardcode the link (https://company.quickbase.com/db/xxxx?a=API_DeleteRecord&rid=13&rdr=WEBSITETOREDIRECTTO), which achieves the same as the JS above, or to Avi's point, would I use like a PHP POST to hide the apptoken?