How to duplicate file object?

Hi!

I the app we have a database connected file object Vedlegg. I would like to copy that object. I have tried to use ‘duplicate objects’ action node, with Vedlegg as source, and Vedlegg MANY (runtime only) as a destination, and then persisting Vedlegg MANY.
File was copied, but the file size is 0 and Original file name is undefined.

Screenshot 2024-01-30 at 14.59.22

Am i doing something wrong?

Thank you

Hi,

Thank you for your question!

The recommended way to duplicate a file object is to use the Create File Object action node. The source type can be changed to URL, and here you can use the File Content URL of the file you wish to duplicate. It will then look something like this:
image

Rhys

Thanks. Since i need to copy multiple attachments, i will then need to iterate through them and copy each one. That is not the most elegant solution, but it works. I would recommend to write somewhere in the documentation that it is not recommended to use ‘duplicate objects’ action node on the file object class (because it won’t work).

1 Like

Hi
I had the same issue, couldn´t find out why duplicating file objects didn´t work. If it is a limitation it should not be possible to try it (at least it should give an error in create).

To get it working, it should also be documented that you can not provide the file content URL as the URL for the new object (as it is not a string and will throw an exception for this) but you need to use the function editor and get the “file content link” from the duplicated object which is not available in the Data binding selector.

So this is quite far from “straight forward”.

  • Expected behavior: duplicating file objects is fixed in appfarm create
  • As a workound: file content link should be available or when choosing the file content URL it is casted to a string.
  • As a minimum - give a warning that you are trying to do something that is not supported.