How to copy (transfer) attached files from one object to another

Hello everyone,

 

I need some help with transferring the attached document records from a User Role named 'Client' into an Object named 'Documentation'. How can I do this?

 

I have already copied the document file upload fields from Client into Documentation. Now I just need to somehow copy the file uploads themselves. 

 

Exporting everything from Client as a .csv and then importing to Documentation as .csv does not work.

 

Thank you in advance for the help.

Hi Luke and Julian,

I think I'm right in saying that Julian's Integromat solution points to the same file. That is, no new file is created. And therefore you run the risk of deleting your original record and losing the file.

I recently needed to move file attachments from one object to another and I also used Integromat. This is how I did it.

![](upload://1W1ogGglCBPS9IIbnNzZo7HN9ca.png)

![](upload://nkaT3f9ACY3hCyEjmPs95WK1cA6.png)

 

![](upload://8wbSIv1ljrd2NLKHtV3o9lut8GF.png)

 

 

![](upload://hAm9Btwvbypz0Ta2lT25xAZIPna.png)

 

This method creates a new file and can be used to transfer files from one knack application to another.

 

Thanks,

Interesting, 390159438391. I wasn't sure if something like that would happen. In that case, Julian's solutions is probably better for this.

@Julian Kirkness

 

I am well versed in Integromat. Personally, I really do like it.

However, I was hoping for a more integrated solution within Knack itself. Although, if this works flawlessly then I am happy to use this solution instead. Thank you for the assist Julian!

@Tony O'Brien 

Oh gosh! Thank you for the heads up.

This was a huge concern of mine. I was wondering if this could be the case and it seems that it could well be a huge issue.

I realise this has been answered - but when I read it just now I was intrigued and decided to experiment with a different approach. You can use Integromat to do this very easily using just a two module Scenario.

The first module searches for the existing records with the files attached and the second creates new records in another object linking the file with the ID:

![](upload://v0MlLjVdFzt1OdoKECfQzS8QFoC.png)

 

Of course this could be made more sophisticated - it may be necessary to find the record to attach the file to if it's an existing one or you may want to remove the file link from the current record. 

 

 

Hi Luke and David,

I'm not exactly sure how attachments with multiple records pointing at them work within the Knack environment. Suffice to say I have had confusing results in the past with attachments like this.

In your case Luke, be very careful deleting the fields linking to the attachments in the Client. This may remove the actual attachment from the database too. Even though you now have a Documentation record  pointing to that attachment.

In some cases, when a field linked to an attachment is deleted all will seem well. Then some days later, the actual attachment gets removed. That means your link from Documentation will work for a while, and then not.

 

 

 

Glad I could help! :)

Hello David,

Thank you so much for your assistance, you are a legend.  This solved my problem.

I'll keep you in mind if I have any future queries.

Hey Luke,

To do what you're looking for, you need to provide Knack with the file ID instead of importing just the URL you get from the export. To do this, first open your CSV export in Google Sheets, Excel, LibreOffice Calc, or similar and replace your file column (the one that contains the file's HTML, eg. <a href="...) with the formula in cell B3 in this example spreadsheet I made to extract the file ID, replacing the cell reference with the column that contains the file URL (should be the column to the right of it). Export the spreadsheet to a CSV.

When importing, select Map to for your file column. Then, right click the field dropdown and click Inspect Element. This should bring up a panel on the side of your browser, with <select name="field_key"... selected. Click the small arrow to the left of that select element, double the field key in value and change it to the field key of your file field. Proceed with your import, and when done it should point to the same file!

I know it's a bit tedious, but this is the easiest way to go about this without introducing some custom code.

If you need any further help or clarification, feel free to contact me directly at david@hmnd.io. I'm also available for any other Knack development or consulting needs you may have.