Forum Discussion

VivekVishwanat3's avatar
VivekVishwanat3
Qrew Cadet
7 years ago

How to handle Deletion of the record in QuickBase?

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.
  • 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.
    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      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.