ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

How to copy an attachment from a doctype to another doctype


#1

Hi,
I wonder if it’s possible to copy an attachment inside a doctype to another doctype using python or js.
I created a Doctype where I attached ‘something.png’. When I submit the document I create an Expense Claim, but I didn’t find a way to attach ‘something.png’ to the newly created Expense Claim.

Is there a way to do that?


#2

Hi,
I think it’s possible to select an attachment from the uploaded files also visible under File Manager or maybe you are trying to achieve something entirely different?


#3

Hi @mwai,
what I want to do is copy the attachments from Doctype1 and paste it in Doctype2 using python or js.

Here are more details:
In a custom Doctype, I created a ‘Simplified Expense Claim’ (so the user can enter the amount, date, reason…) and attach the image of the invoice.
Once this document is submitted, I take the given information and create a real Expense Claim. The whole process is working fine, except for the attachments. I would like to take the image from ‘Simplified Expense Claim’ and add it inside ‘Expense Claim’ when I create it. The process should be done by code only.

Any Ideas?