Try ERPNext Buy Support Partners Foundation

Attaching files through custom script

I’m trying to create a custom script that will attach files to the RFQ document by scanning through the items that are in the items table when a button is pressed on the Document. I can’t seem to find any code for attaching a web link to a document without using a custom Attach field (which I don’t want to do).

T “Attachments” >> “Attach File” option on the left of the screen (which is in most documents) is the functionality I want to access, but I can’t figure out how to.

Any tips/suggestions? I’m happy to use a server or client side script, whichever is easier.

Any suggestions?

I’m assuming that the files you want to send in the emails are already attached to the Items themselves, and you just want those attachments to send along with the outgoing email. If that’s the case, couldn’t you create a button that scans the attached_to_name field in the file doctype for matches with your RFQ items list, and then create new entries in that doctype for the same file URL attached to the RFQ, then reload the form?

The file doctype is in the core module in Frappe

The system seems to recognize that duplicate URL’s have no extra file size, and give an option to send any files with the email that are attached to the document.

That said, the “Send Supplier Emails” button might need to be modified to send the attachments by default.

Hope this helps

Hello @Ben_Cornwell_Mott, did you solve this problem?
We also need to attach files to a PO which is attached to Item.

Hi @Ben_Cornwell_Mott , did you solve this problem?
We also need to attach files.

You may find a reference here https://github.com/frappe/erpnext/wiki/Community-Developed-Custom-Scripts#attachment-transfer

I’ve also developed a script to make attachments but it was my first script so there are some flaws.