Is there any way to capture the Not Saved Documents?

Hi,

My use case is I have written some workflow, and few things were written on the document later on.

As per the workflow if the document’s old_state is “Approved” and new_state is “Approved” then no one can change the document.

Issue is earlier it was allowed to changed an Approved document, now what happened few of the users have attached some files to the Approved Item doctype (where no restriction was there to change update an approved document) but didn’t save the Item Doctype, which creates the situation where item’s doctype old_state is “Approved” and new_state is “Approved” but it is not saved now, whenever anyone wants to attach anything to the document it says not allowed, and ask to save the document first which is not allowed by the code.

I was looking for something by which we may know that document is Not Saved

Any idea about this?

Not understood your problem.
But you can identify unsaved document using following lines.

In .js

cur_frm.doc.__unsaved

In .py

self.get('__unsaved')

@Sangram
I tried it in JS but it says undefined.

Regards
Ruchin Sharma