Forum Discussion

GiuseppeMacri's avatar
GiuseppeMacri
Qrew Captain
6 years ago

Remove file attachment with button

Hi, I was wondering if there was a way to remove file attachments from a form using a button?

------------------------------
GMacri
------------------------------
  • Not tested but my notes say that this will work.  Can you post back with your working code when it works?

    URLRoot() & "db/" & dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
    & "&_fid_9="
    & "&delfile_fid_9=1"
    // & "&apptoken=<your apptoken>"

    // obviously 9 would be replaced with the field ID of your file attachment field.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------
  • The complete code would be this


    var text URL = URLRoot() & "db/" & dbid() & "?act=API_EditRecord&rid=" & [Record ID#]

    & "&_fid_9="
    & "&delfile_fid_9=1";


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


    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------
    • GiuseppeMacri's avatar
      GiuseppeMacri
      Qrew Captain
      Hmm, this would work great but I'd require some additional tweaking:

      1. When regarding the removal, i mean as though an individual uploaded the wrong file, saw the issue, and instead of clicking upload file and hitting cancel, is there a way to get create a button which just removes all "Pending" file attachments

      2. Don't want to expose the API token to the end user at this time.

      ------------------------------
      GMacri
      ------------------------------
      • GiuseppeMacri's avatar
        GiuseppeMacri
        Qrew Captain
        Bumping this post

        ------------------------------
        GMacri
        ------------------------------
    • GeorgeBramhall2's avatar
      GeorgeBramhall2
      Qrew Cadet
      Anyway to do this without using the suggested javascript?

      ------------------------------
      George Bramhall
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        sure, here you go ......

        var text Delete = URLRoot() & "db/" & dbid() & "?act=API_EditRecord&rid=" & [Record ID#]

        & "&_fid_9="
        & "&delfile_fid_9=1";


        var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

        $Delete
        & "&rdr=" & URLEncode ($RefreshPage)


        ------------------------------
        Mark Shnier (YQC)
        mark.shnier@gmail.com
        ------------------------------