Trigger point for Not Saved status

Hi @all,
The use case is to find the trigger point for Not Saved status.

For example when the use edits something in the doctype the status gets changes to Not Saved, on what trigger point we get that?

Regards,
Prasanth

Hi @Prasanth_Kumar_J
You can use frm.dirty()

Set form as “dirty”. This is used to set form as dirty when document values are changed. This triggers the “Not Saved” indicator in the Form Views.

for your reference:-
https://frappeframework.com/docs/user/en/api/form

1 Like

Hi @Safvan_Ph

thanks for the reply
Already tried with the following code
When we have the changes, then we want this button to be displayed.
if(frm.is_dirty()){
frm.add_custom_button(__(‘Save & Submit’), function(){
if(frm.is_dirty()){
frm.save();
}
sleep(1500).then(() => {
frm.trigger(‘before_submit’);
if(frm.doc.status === ‘Ready’ && !frm.is_dirty()){
frm.trigger(‘on_submit’);
frm.save(‘Submit’);
}
});
}).css({“color”:“white”, “background-color”: “#2490ef”});
}

Hi @Prasanth_Kumar_J,

Please try it.

if(frm.is_dirty()) {
    frm.add_custom_button(__('Save & Submit'), function() {
        frm.save('Save').then(() => {
            // After saving, you can add your additional logic.
            if(frm.doc.status === 'Ready') {
                frm.trigger('before_submit');
                frm.trigger('on_submit');
                frm.save('Submit');
            }
        });
    }).css({"color": "white", "background-color": "#2490ef"});
}

Thank You!

Hi @NCP,

Not working, button was not coming up when the status is Not Saved.

Regards,
Prasanth