Feature: Warning popup when doctype is not yet save

Trying to create a new feature for Frappe framework.

Use Case:

When the user is editing a record in a certain doctype and He/She decided to transfer to any other menu and the doctype status is not save
it will warning popup to save or cancel. If he chooses to save it the record is save.

Why we need this?

I let user try ERPNext and one of the problem they found is sometimes they forgot to click save and they have already encoded lots of record and specially a lot of record in a child table (e.g. Sales Order and Sales Order Line) and they transfer to another tab all they encoded is GONE :frowning:

@max_morais_dmm Maybe you have a comment on this you are javascript guro :smile:

Maybe other community member has idea the best way to implement this :slight_smile: I have already created git issue Warning popup when doctype is not yet save · Issue #1536 · frappe/frappe · GitHub

@ccfiel, this is the event frappe/router.js at develop · frappe/frappe · GitHub, but frappe keep the record on cache!

I would like to vote this issue up, this has happened to me in a demo 5 minutes ago.


@max_morais_dmm We have already discuss it with @anand here is what we plan to do as suggested by @anand

  1. I think a better way to handle this is to show Unsaved documents in the List view instead of showing an annoying popup every time. This will also save us from adding that extra configuration option. This might be tricky but would have the right UX.

  2. Before closing a tab, the code should look for any unsaved document and warn the user about it. If the user tries to do a full refresh or close the tab, show pop up that following documents are unsaved. Are you sure you still want to refresh/close?

All opened documents are already saved on the client side in window.locals (better api is frappe.model.get)

@ccfiel, yes I’m following the comments! Thank you so much to share :smile:

1 Like

Is this topic somehow solved?
I just could close a document that was not saved on my V13 playground instance…


refresh: function(frm) {
        window.onbeforeunload = function() {
                if(frm.is_dirty()){ return 'A valid String';}
                else { return; }

This is inbuilt now