How to handle Deletion of the record in QuickBase?

  • 0
  • 1
  • Question
  • Updated 3 months ago
  • In Progress
Hi, I have a table

Record ID           Value
1                           20
2                           21
3                           19
4                           15
5                           25



Deleting a record should be made possible only if Record ID is having maximum Value.
i.e., here in this situation Record ID=5 deleting should be possible and deleting Record ID=4(or) below, should not be possible.
Photo of Vivek Vishwanath

Vivek Vishwanath

  • 474 Points 250 badge 2x thumb

Posted 3 months ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,332 Points 20k badge 2x thumb
Code similar to this will hide the delete button on the ?a=er page if the [Record ID#] is not the largest [Record ID#] value in the table:
(function(){
  var dbid = "";
  var dbidRecords = "";
  var apptoken = "";
  $.ajaxSetup({data: {apptoken: apptoken}});
  var querystring=document.location.search;
  if(/a=er/i.test(querystring)) {
    $.get(dbidRecords, {
      act: "API_DoQuery",
      clist: "3",
      slist: "3",
      options: "num-1.sortorder-D"
    }).then(function(xml) {
      var maxRid = $("record_id_", xml).text();
      if (kRid !==  maxRid) {
        $("#deleteButton").hide();
      }
    });
  } 
})();

However, there are other mechanism by which a record can be deleted and you would have to identify and handle those cases as well. 

As much as I think script solutions are superior you might want to rethink your workflow and see if you can use roles or other native features so achieve your goal.
Photo of Vivek Vishwanath

Vivek Vishwanath

  • 474 Points 250 badge 2x thumb
Hi Dan, Thank you for responding. what is "dbidRecords"?

Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 26,242 Points 20k badge 2x thumb
These statements are boilerplate in many scripts and are included even if they are not used:
var dbid = "";
var dbidRecords = "";
var apptoken = "";
$.ajaxSetup({data: {apptoken: apptoken}});
By convention dbid is the dbid of the application, dbidRecords is the dbid of Records table and apptoken is the application token.