Thursday, December 29, 2016

X++ code to validate Name using Regular Expression in AX 2012


public bool validateName(str _name)
{

    System.Text.RegularExpressions.Match regExMatch;
    bool                                 isValid;

    // verify that Name doesn’t contain bad special character like <>:”/\|?*
    // other characters used in the regular expression are part of regex syntax. 

    regExMatch = System.Text.RegularExpressions.Regex::Match(_name, @’^[^<>:"/\\|?*]*$);
   
    // return true if name matches the criteria otherwise return false
    isValid = regExMatch.get_Success();   

    return isValid;
}

No comments:

Post a Comment

Export a copy of the standard user acceptance testing (UAT) database

 Reference link: Export a copy of the standard user acceptance testing (UAT) database - Finance & Operations | Dynamics 365 | Microsoft ...