Discussions

Expand all | Collapse all

File attachment from request form/table to elsewhere in the app via automation/JS

  • 1.  File attachment from request form/table to elsewhere in the app via automation/JS

    Posted 08-06-2019 18:36
    We have an app where the workflow starts with a Request Table/Form... information from there is then used to create new rows as needed in two other tables, but do not have a relationship with the Request table.

    This so far works great. However one of the fields is a file attachment. Would it be possible to use JS to pull the file attachment, and then upload it to another field/table through the API?


  • 2.  RE: File attachment from request form/table to elsewhere in the app via automation/JS

    Posted 08-06-2019 20:14
    You can I believe - the tricky part is the download. You can use API_EditRecord or API_uploadFile to do the upload - but the download, I believe you have to do a GET to the download URL and play with the contents. 

    Try out doing a GET against the download URL format: https://realm/quickbase.com/up/dbid/a/rRID/eFID/v0 - that theoretically would give you the raw Base64 contents to just copy over to your new record. I've only work with the uploads - so I'm not 100% confident with the answer.

    Chayce Duncan | Director of Strategic Solutions
    (720) 739-1406 | chayceduncan@quandarycg.com
    Quandary Knowledge Base


  • 3.  RE: File attachment from request form/table to elsewhere in the app via automation/JS

    Posted 08-06-2019 20:17
    That makes sense... Looks like I would need to do a GET for the download URL... then a GET to get the base64... then POST once I have the payload of base64. That makes sense.

    I think I was being greedy in trying to do it all in one original GET... Thanks for the pointer, Chayce.


  • 4.  RE: File attachment from request form/table to elsewhere in the app via automation/JS

    Posted 08-06-2019 20:35
    Is there a reason you need to actually move the file? Have you considered just passing a URL and keeping the file in the original spot? It is seamless to the user.


  • 5.  RE: File attachment from request form/table to elsewhere in the app via automation/JS

    Posted 08-06-2019 20:40
    I'm currently thinking it would be easier given that the location table has some custom code to view files from the browser... though it's worth looking into...

    As I'm typing this, that might be the way that I'm going.


  • 6.  RE: File attachment from request form/table to elsewhere in the app via automation/JS

    Posted 01-20-2020 16:31
    Apologies if the answer is right under my nose....but if I want to take your suggested approach of just populating the file attachment URL in a text field- what's the easiest way to do that if I don't want to have a button or anything clicked?.... I just want to populate the URL of a file attachment field (latest version always) automatically and assuming there is a file in the file attachment field....   once I do that I would then share that field down to my child table and then I'd be good to go (for what I need to do)

    Thanks for the help

    ------------------------------
    Scott Pugh
    ------------------------------



  • 7.  RE: File attachment from request form/table to elsewhere in the app via automation/JS

    Posted 01-20-2020 16:42
    Scott, does this answer your question?
    https://community.quickbase.com/communities/community-home/digestviewer/viewthread?MessageKey=6d1551ee-2bba-4e75-9a0b-082252b1df75&CommunityKey=d860b0f8-6a48-487b-b346-44c47a19a804&tab=digestviewer#bm6d1551ee-2bba-4e75-9a0b-082252b1df75

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------



  • 8.  RE: File attachment from request form/table to elsewhere in the app via automation/JS

    Posted 08-08-2019 13:42
    Ok so I'm trying your suggestion Harrison, to at least get it somewhat working.. and I have a really basic problem.

    I get the URL of the File attachment, and the plan is to populate that link into a text field on the other table... 

    I'm getting the infamous "edit record, 0 error, 0 fields changed" api message.

    https://<realm>.quickbase.com /db/<dbid>?a= API_EditRecord &rid=1& fid_39_=https:// <realm>.quickbase.com /up/ <dbid> /g/rb/ebg /va/TestInvoice12345.pdf

    I'm sure I'm missing something obvious.

    **Added spaces in the API URL so you can read it all**


  • 9.  RE: File attachment from request form/table to elsewhere in the app via automation/JS

    Posted 08-08-2019 13:54
    Figured it out... I forgot the leading underscore for _fid_39_