Error: Document has been modified you have opend it...please refresh this page

Hi,
I am trying to add a row in the child table and i am filling the details after that i am saving that record but i couldn’t save it, because (Error: Document has been modified you have opend it…please refresh this page) this error is displaying…any idea to resolve this issue
Thanks,
Nivedha

Hi Again,
any idea for this issue?
Thanks in advance

This issue occurs when the modifying time of document is changed after the page load which may lead to change in modified time before & after saving a document do not update the document before submit or before save

1 Like

This isn’t an issue - it is just a safety mechnism to ensure data integrity. Just follow the recommendation and refresh the screen (preferably before you start adding data)

1 Like

Hi,
Thanks for the reply @nouman, @trentmu same error is displaying i refreshed the page but i could not able to save the record. repeatedly the error is displaying…any idea?

is any one using this data parallel ?

Please share what you are doing.

Thanks for your reply @bhavikpatel7023 i am trying to create another record from the childtable field i.e a checkbox which fieldname is request when i try to save the record after entering the childtable entries the request checkbox has been changed into enable and the record will be created only for the first time…if i add the row after the 1st row then i could not save the record there the error is displayed even i refreshed the page.

Could your share your JS and py code which you implemented and share your usecase. So we can help it out.

before_save: function(frm, cdt, cdn) {
                if (frm.doc.workflow_state == "Impact Approved"){
                        var d = locals[cdt][cdn];
                        frm.doc.feedback.forEach(function(d) {
                   
                return frappe.call({
                        method:"populate_lots",
                        args: {"docid":frm.doc.name},
                        callback: function(r){
                                d.request = 1;
                                d.status = "Requested";
                                cur_frm.refresh_field("feedback");}
                        });
                })
        }
}

this is my js code

@frappe.whitelist()
def populate_lots(docid):
        doc = frappe.get_doc("doctype name",docid)
        for j in doc.get('feedback'):
                        create_ia(j.name,j.department,doc)
                        frappe.msgprint("Department.")
                        doc.save()

def create_ia(row,dep,doc):
        ia = frappe.new_doc("new doctype name")
        ia.save()
        ia.cno = doc.name
        ia.status = doc.status
        ia.change = doc.change
        ia.reason = doc.reason
        ia.actions = doc.actions
        ia.category = doc.category
        ia.number = doc.number
        ia.changes = doc.changes
        for k in doc.get('feedback'):
                if k.department:
                        ia.row_name = row
                        ia.department = dep
                        ia.save(ignore_permissions = True)

this is my py code

populate_lots and create_ia Save document which you opened via UI?

yes i will check this in UI

End of the js just use frm.refresh() then try to save.

Thanks @bhavikpatel7023 but no response from UI same Error is shown.

Could you tell me name of doctype in js and in Py?

In before_save you are making a py call which saves the doc? Can you move the js logic to validate in py?

Hi @bhavikpatel7023,
new doctype name : IA
doctype name: CC

Thanks for the reply @vijaywm, how can i move this into py? can u suggest me any idea?

def validate(self):
    if self.workflow_state == "Impact Approved":
        for d in self.feedback:
            ia = frappe.new_doc("new doctype name")
            ia.cno = self.name
            ia.status = self.status
        ...

try something like that… validate will be called before doc is saved

Hello @Nivedha i was getting the same error,after that i tried to update the financial date with same date and the issue was resolved.