Forum Discussion

JordanBeatty1's avatar
JordanBeatty1
Qrew Captain
8 years ago

Delete a record without going into grid edit or going into the selected record

Hi, is it possible to delete a record from the table view with quickbases native features?
  • No problem,
    You can make a URL formula button to delete a record and refresh the page. But there is no "are you sure" step on this so be careful.

    var text URL= URLRoot() & "db/" & Dbid() & "?act=API_DeleteRecord&rid=" & [Record ID#]
    & "&apptoken= xxxxxxx";


    "javascript:" &
    "$.get('" & 
    $URL & 
    "',function(){" &
    "location.reload(true);" &
    "});" 
    & "void(0);"


    if you have application tokens enabled on the app properties tab for the application, then you will need to supply that long code number.  or else just disable them as not being needed.
  • MCFNeil's avatar
    MCFNeil
    Qrew Captain
    If you want to take is a step further... what happens to all the child records of the parent you delete?  
    They become lost in space, and really reek havoc on your reporting.
    .
    .
    In comes "Clean Delete" to save the day.  We have a tool that will delete, in one click, the parent, the children, and grandchildren records.


    QuickBase is about data, but if your data becomes 'dirty' over time, its hard to trust the reports.
  • Tying to  QuickBaseCoach App Dev./Training, Champion answer, You can do something like this for confirmation:

    var text URL= URLRoot() & "db/" & Dbid() & "?act=API_DeleteRecord&rid=" & [Record ID#]
    & "&apptoken= xxxxxxx";

    "javascript: " &
    "if ( confirm('Are you sure you want to permanently delete this record ? ') == true ){ "&
    "$.get('" & 
    $URL & 
    "',function(){" &
    "location.reload(true);" &
    "});" 
    & "void(0);"&
    "}
  • Trying to figure out how to use this to delete a child record in a embedded report.  It is a line item on an order form, and I want to have the option to delete the line item.  The record ID# does not appear on the embedded report used to enter line items.
    • MarkCorcoran's avatar
      MarkCorcoran
      Qrew Cadet
      Yeah, I've tried it.. It refreshes the screen, but the record is still there.
       
      This is what I have as a Formula-URL Button in an embedded report.

      var text URL= URLRoot() & "db/" & Dbid() & "?act=API_DeleteRecord&rid=" & [Record ID#]
      & "&apptoken= d7xnw2xdw9v4qnrm2ptkcyndgx3";


      "javascript:" &
      "$.get('" & 
      $URL & 
      "',function(){" &
      "location.reload(true);" &
      "});" 
      & "void(0);
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      The code is failing and refreshing the screen.

      To debug it when using that JavaScript method, you would just run the URL itself without the JavaScript stuff

      Ie, comment out the JavaScript and just instead do $URL

      What you will find is an error saying invalid application token.

      You will then recheck it until you go cross eyed or until you notice it has an embedded leading space after the = which is causing the code to fail.
    • MarkCorcoran's avatar
      MarkCorcoran
      Qrew Cadet
      Wow.. thanks, I never noticed the leading space on the app token.  Thank you, it works like a charm now.