How to handle the 'track changes' portion of the ERPNext?


I want to help from your side.

I am getting the documents from the API and I want to store that document in the footer of the record. (The area in which we can track our record changes.) For better understanding, I am sending you the screen shot of that part.

So, How to handle that processes through the code.

Waiting for the response.

Thank You.

You can add the comment to the document which you are fetching using doc.add_comment method

1 Like


Yes. But I got the response from the api in terms of image binary code. So, with the use of comment_type=“Attachment”, how can i store my image?

Please help to do this.

Can anyone help me to solve this problem?

Hello There,

For creating an Attachment one needs simply to create a new record for File doctype

The values could be passed as -

File_doc.attached_to_name = 'Test'

And then the changes will be automatically tracked as the File doctype itself has the track_changes=Enabled.

Another request I had to copy any existing attachment to the new doctype, which could be achieved by

JS part (Could pass in args in a function)-

"attach_files": frm.get_files()

Python part (Copy the file dict and add to a new doc and save -

newfile_doc = []
newfile_mdata = frappe._dict(json.loads(attach_files))
newfile_mdata.update({'file_size': doc.file_size, 'doctype': "File", 'attached_to_name': 'Test', 'attached_to_doctype': 'New Doc Sales for eg'})

Hope this helps, thanks!