Support Article
Dirty popup issue with save
SA-48105
Summary
User has implemented the 'Save' using a custom button.
After clicking on save, the screen should not be reloaded and so user is calling the doSave activity alone to achieve it.
But in such a case, if they try to close the tab which has been saved and not re-loaded, a dirty pop-up appears, which is not required.
Error Messages
Not Applicable
Steps to Reproduce
1. Include a button configured with onClick doSave activity.
2. Click on the button, the form gets saved and then close the work-object.
3. Observe that a dirty pop-up with "You are about to discard your unsaved changes" pops up which is not required.
Root Cause
An issue in the custom application code or rules.
Though the save has been performed, the form would still be dirty as the form has not been reloaded.
And user could see the dirty pop-up. This is an expected behavior.
Resolution
Perform the following local-change:
To get rid of the dirty pop-up upon save, the dirty flag can be disabled and then that has to be enabled later.
1. Place the below script in the harness level javascript file
<script>
function overrideDirty(){
pega.u.d.gDirtyOverride = false;
}
function resetOverride(){
pega.u.d.gDirtyOverride = null;
}
</script>
function overrideDirty(){
pega.u.d.gDirtyOverride = false;
}
function resetOverride(){
pega.u.d.gDirtyOverride = null;
}
</script>
2. Add a run script action for save button after run activity to call overrideDirty. Setting this flag ignores the dirty handling.
3. But there are few cases like modifying the UI element after save, where user need to show the dirty warning.
For that the override flag has to be reset, on change of all the fields on the screen. For this, add a runscript on change of all the input fields that are present on screen to call resetOverride function.
This local-change would not be suitable if there are lot of fields on screen.
“isFormDirty” is the function which checks whether the form is dirty or not. “isFormDirty” is defined in pzpega_ui_doc_dirtyhandling.js file.
If the dirty check has to be ignored on every close, in function “closeWork : function (event, dcCleanup, dcCleanupCallback, ignoreDirty)”, ignoreDirty param must go as ‘true’. This wouldn't be easy to achieve.
Perform the below steps if the changes are to be reflected on a particular section (locally):
- Create a non auto generated section
- Include the above code in the HTML tab of the section
- Include the non-auto section in another section where the changes are to be reflected
Perform the below step if the changes are to be reflected across the application:
Add the above code to the UserWorkForm.
Published October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.