Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Email address validation rule does not work in a table layout

SA-85740

Summary



In Pega Platform 8.1.5, the following issues occur:

Issue 1: In the email address, the out-of-the-box Edit Validate rule validates only [email protected] xyz and not [email protected]
Issue 2: The Email address Validation error message does not diplay in the table layout.





Error Messages



Not Applicable


Steps to Reproduce

  1. Create an Email property and use the out-of-the-box 'ValidEmailAddress' Validation rule. At runtime, the email validates only [email protected] xyz and not [email protected]
  2. Add the email property in a table. The error messages display as a tooltip.


Root Cause



The out-of-the-box 'ValidEmailAddress' validation rule validates only [email protected] xyz.
Customization must be performed based on the user's requirement. Additionally, the email address Validation error message not diplaying in the table layout and appearing as a tooltip is working as per Pega product design.



Resolution



Perform the following local-change:

For Issue 1:
  1. Create a EditValidate rule with the below code,

    if (theValue == null || theValue.trim().equals("")) return false;
    try {
                javax.mail.internet.InternetAddress emailAddr = new javax.mail.internet.InternetAddress(theValue);
                emailAddr.validate();
     }
    catch (javax.mail.internet.AddressException ex){
       return false;
    }
    if(theValue.contains("."))
        return true;
     
    theProperty.addMessage("Enter a Valid Email Address");
    return false;

     
  2. For client side validation, use 'Post Value' for onchange event of the property outside the grid or add the below script in UserWorkForm,

    <script>
    var ruleEditValidate_validEmail = new validation_ValidationType("validMail", ruleEditValidate_isValidEmail);

        ruleEditValidate_validEmail.addEventFunction("onchange", ruleEditValidate_isValidEmail);
      
      f
    unction ruleEditValidate_isValidEmail(object) {

        var x = pega.control.PlaceHolder.getValue(object);
        if (null == x || "" == x) {
            return;
        }
        // Regular expression for email address
        // RFC822 regular expression
        var emailReg = /^\[email protected][a-zA-Z_]+?\.[a-zA-Z]+$/;
        var validMail = emailReg.test(x);
        if (!validMail) {
            return display_getValidationError(object, ruleEditValidate_isValidEmailAddressMsgStr, "", true);
        }
    }

    </script>

    Note: ValidMail (Mentioned in above script) is the custom Edit Validate rule created. The above script is required to validate the property inside the grid.

For Issue 2:

For the error message to display in the grid, include the Email property control in a section in the grid Cell properties.

Published August 15, 2019 - Updated December 2, 2021

Was this useful?

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.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us