Support Article
Validation rule does not prevent modal window submission
Summary
A modal window is configured with various properties with validations configured on them.
For some properties, even though the validation fails, it does not prevent modal window from submission.
Error Messages
Not Applicable
Steps to Reproduce
- Launch a modal dialog (not associated with the pyWorkPage or a work object, but on Data-Portal page)
- The modal window section should include properties both directly on the Data-Portal page and from other pages.
- Run validations using validation rules associated to the local action launching the modal.
- Failing validation on the property configured on the Data-Portal page prevents the modal window submission.
- But failing validation on properties belonging to other pages do not prevent modal window submission.
Root Cause
Validation failure of the property belonging to Data-Portal sets the error messages on pyDisplayHarness. This prevents the modal window from submission until the error is cleared. However, when a property belonging to a different page fails validation, the error messages are set on the page the property belongs to. In the above case, when AddressPage.pyPhoneNumber fails validation, the error messages are set on AddressPage and not on pyDisplayHarness. Since no error messages are found on pyDisplayHarness, the modal window is allowed to submit even when errors are present.
Resolution
Copy any error messages set on other page properties to pyDisplayHarness.
Activity details:
String SourcePagesString = tools.getParamValue("sourcePage");
ClipboardPage TargetPage = tools.findPage("pyDisplayHarness");
if (SourcePagesString.length() > 0 && TargetPage != null) {
String[] SourcePages = SourcePagesString.split(",");
if (SourcePages != null && SourcePages.length > 0) {
for (int index = 0; index < SourcePages.length; index++) {
String SourcePageString = SourcePages[index];
if (SourcePageString.length() > 0) {
ClipboardPage SourcePage = tools.findPage(SourcePageString);
if (SourcePage != null) {
String SourceErrorMessages = SourcePage.getMessagesAll();
if (SourceErrorMessages.length() > 0) {
TargetPage.addMessage(SourceErrorMessages);
}
}
}
}
}
}
Published June 1, 2017 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.