Discussions

 View Only
  • 1.  Pipeline to remove file attachments

    Posted 06-02-2023 09:39

    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
    ------------------------------


  • 2.  RE: Pipeline to remove file attachments

    Posted 06-02-2023 09:51

    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
    ------------------------------



  • 3.  RE: Pipeline to remove file attachments

    Posted 06-02-2023 10:51

    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
    ------------------------------



  • 4.  RE: Pipeline to remove file attachments

    Posted 07-02-2023 19:47

    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
    ------------------------------



  • 5.  RE: Pipeline to remove file attachments

    Posted 07-02-2023 19:54

    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
    ------------------------------