Reverting a submitted document back to Draft

Hi,

I am trying trying to change the status of a document from ‘submitted’ back to ‘Draft’ for more updates. I am planning to do that by adding a ‘Revert To Draft’ button in ‘Submitted’ state. This looks like a generic usecase, so wondering if there is already some support to this in some other way. If not, I am guessing I need to write a whitelist function and call that from the button handler in javascript. Please let me know if that this is not the right way of doing it.

Regards
Sathish

Hi,
If you know after submitting any document you can ‘Cancel’ it first then ‘Amend’, change/update document and save it status become “Draft”.

Submit->Cancel->Amend->Save

Thanks @shraddha,

I gave ‘cancel’ permission to the doctype and could cancel the record. However I don’t see any button to ‘amend’ the same. I tried duplicating the record, but that fails due to name conflict with original record. Is there anything more to do to get the ‘amend’ button?

@spoojary . Open the doctype and check the amend box in the permission rules child table for that particular user

Thanks

Great. Thanks @shraddha,

I could get the amend button visible after cancelling. However still couldn’t get the flow working. Basically I am trying to add two doctypes:
Course Content: With a list of chapters for a subject
Chapter Content: A chapter with some notes and references, with a link to course content

I can cancel a ‘course content’, but amending it results in following failure

11:28:59 web.1 | File “/home/spoojary/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/cursors.py”, line 205, in execute
11:28:59 web.1 | self.errorhandler(self, exc, value)
11:28:59 web.1 | File “/home/spoojary/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
11:28:59 web.1 | raise errorclass, errorvalue
11:28:59 web.1 | DuplicateEntryError: (u’Chapter’, u’Insects’, IntegrityError(1062, “Duplicate entry ‘Insects’ for key ‘PRIMARY’”))
11:28:59 web.1 |

whereas ‘cancel’ on Chapter Content fails due to its linked doctype

11:37:49 web.1 | File “/home/spoojary/frappe-bench/apps/frappe/frappe/init.py”, line 279, in _raise_exception
11:37:49 web.1 | raise raise_exception, encode(msg)
11:37:49 web.1 | LinkExistsError: Cannot delete or cancel because Chapter Content Notes is linked with Course Content UKG-MUSIC

Could you please let me know what exactly happens as part of ‘cancel’ and ‘amend’?