Support Article

Validation rule does not prevent modal window submission

SA-38065

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

  1. Launch a modal dialog (not associated with the pyWorkPage or a work object, but on Data-Portal page)
  2. The modal window section should include properties both directly on the Data-Portal page and from other pages.
  3. Run validations using validation rules associated to the local action launching the modal.
  4. Failing validation on the property configured on the Data-Portal page prevents the modal window submission.
  5. 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.

1. Create an activity with a single parameter “sourcePage”.

1.jpg

2. Include a single Java step, with the contents shown in the screenshot below.

2.jpg

3. Call this activity as the “Post Flow action” activity for the modal dialog involved. Pass as parameter the page name, which contains the property.

3.jpg

Activity details:

String SourcePagesString = tools.getParamValue("sourcePage");

ClipboardPageTargetPage = 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) {

ClipboardPageSourcePage = 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


100% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.