Forum Discussion

KevinGardner1's avatar
KevinGardner1
Qrew Member
2 years ago

Pipeline to remove file attachments

I am trying to investigate if there is a way to use a pipeline to remove file attachments?  I am automating a process to incorporate data into our system using CSV uploads.  The issue is that I would like to keep some of the information from the upload available (e.g. the Requestor, Date Uploaded, File Name) but I don't want to actually archive the file on QuickBase due to space limitations.  Is there a way to just delete the file itself without deleting the entire record?  You can of course click into the file and manually delete it (see below), but I want this to be automated as I won't be doing the uploads myself.  The field type is "file attachment" and it appears to be stored as a URL/Link.  It does not behave like other fields in the pipeline and I have not found a way to override it yet.  Thanks!



------------------------------
Kevin Gardner
------------------------------
  • AngelRodriguez's avatar
    AngelRodriguez
    Qrew Assistant Captain

    Since I can't delete the post, please disregard what I said below this.  I was using GET and not POST when running my Make Request. 

    Also keep in mind that when using this technique, Quickbase still keeps a backup of these files that utilizes your attachment space.  You can find this in App Management > Manage File Attachments.

    • MarkShnier__You's avatar
      MarkShnier__You
      Icon for Qrew Legend rankQrew Legend

      If the number of attachments to retain is set to 1, then, removing that attachment will mean that there are no previous versions retained by Quickbase. 

      • AngelRodriguez's avatar
        AngelRodriguez
        Qrew Assistant Captain

        That's odd. I'm just not getting that result.  Unless I'm doing something wrong here.  When I run this in my Pipeline using the 'Make Request' step (in a for loop for all attachments), it shows the attachment is gone in form and report view:

        https://<my_realm>.quickbase.com/db/<my_db_id>?act=API_EditRecord&rid={{a.id}}&_fid_113=&delfile_fid_113=1

        But when I go to 'App Management > Manage File Attachments' in QB, the attachment space remains the same and shows that all the attachments are still there.

        Ah, I see what I did.  I set to the HTTP method to GET and not POST.  I also needed to set the number of versions to retain for each attachment field to 1. My bad.  What MarkShnier__You and PrashantMaheshw mentioned is correct.

  • I had this problem with a build I did. I ended up using Sharepoint to store the file, that way we didn't use document space on Quickbase. Then I made a URL button to "view the document" so you could pull it up from sharepoint straight from QB.

    • SamCarney's avatar
      SamCarney
      Qrew Member

      PrashantMaheshw, In your post, what is the fid_261? I see you have 3 different fid sections and the other examples have only 2.       I'm also wondering how the system know what table we are working with if we only supply the DB and the RID and the FID.

  • You should be able to use a Make Request Step in A Pipeline.

    First make a formula URL field on the table to have it generate the code.

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

    Then expose that code result and copy paste it into the Pipeline make request URL.

    The carefully hand edit it in the Pipeline step as you need to get rid of the hard coded record ID that you see, and instead drag down the reference to the record ID to be deleted form the trigger step.

    for example it would probably need to be {{a.id}}

    Also I think you need to select it as POST and not GET method.

    Feel free to post back it you have any issues as I did not recently test this.



    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------
    • MikeGerrity1's avatar
      MikeGerrity1
      Qrew Member

      I used your guidance here to create a Pipeline the would delete file attachments in bulk.

      It seemed to work great - if you look at the file attachment field there is no longer any text showing for the file and there is now thumbnail, BUT the file attachment size for this table was unchanged - despite seemingly deleting about 19,000 photos.

      What appears to be happening is that I am deleting the current version - BUT the file that had been there  simply slides down on the version list (current settings are the default "keep 3 versions").     So the file has not been removed per se and the file attachment space is unchanged  (unless I happened to have 3 versions in there previously in which case I assume the oldest one would effectively be deleted).   SEE SCREENSHOT.

      I tried executing the delete button 3 times but that is apparently is not understood by Quickbase as a "new version" - I assume because nothing has really changed for the current version. 


      So now I am thinking the easiest fix would be to change the properties on the file attachment field to only Keep 1 version - I believe all prior versions would be immediately removed but thanks for confirming.

      Before I take that  action thought.  I did find this old discussion which seems to suggest there is an additional VERSION PARAMATER that may be helpful.   I experimented a little bet with trying to add something like Mark had suggest but got no love.

      URLRoot() & "db/" & dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
      & "&_fid_9="
      & "&delfile_fid_9=1"
      & "&vid=1";

      I tried several different options for changing the VID but nothing changed the results - a new "deleted version" was added and the older versions were still there.



      ------------------------------
      Mike Gerrity
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend

        I had something very similar happen to me.

        I'm not sure how many versions you are trying to retain, but assuming that you only need to retain 1 version, change that value to something and then change it back to keep 1 version and it might instantly fix the issue.

        But if you actually do need to keep more than 1 version, I don't have an answer 



        ------------------------------
        Mark Shnier (Your Quickbase Coach)
        mark.shnier@gmail.com
        ------------------------------
    • KevinGardner1's avatar
      KevinGardner1
      Qrew Member

      Thank you Mark!  That did the trick. 

      Just wanted to post a clarifying point for anyone reading this that the "9" that was posted in the code corresponds to the field id of the File Attachment field.  So, that will have to be updated to whatever your field id is in your table. 

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



      ------------------------------
      Kevin Gardner
      ------------------------------