Code snippet of how to use the function setDirtyFlag.
Preview

Example
/**
* @description Set the dirty flag to true cause the user enters the edit mode.
* Unsaved changes in the application can lead to potential data loss.
*/
edit: function() {
sap.ushell.Container.setDirtyFlag(true);
},
/**
* @description Submit changes and set dirty flag to false cause there are no unsaved changes anymore
*/
save: function() {
var oServiceModel = this.getOwnerComponent().getModel;
oServiceModel.submitChanges({
success: function(oData) {
//process batch response
sap.ushell.Container.setDirtyFlag(false);
},
error: function(oErr) {
//errorhandling
}
});
},
/**
* @description Reset changes and set dirty flag to false cause there are no unsaved changes anymore
*/
cancel: function() {
var oServiceModel = this.getOwnerComponent().getModel;
oServiceModel.resetChanges(undefined, true);
sap.ushell.Container.setDirtyFlag(false);
}
