Friday, December 30, 2016

Validate Email Id in ax 2012

static boolean validateEmail(str _email)
{
    str emailAddressFilter = @"^[^@]+@[^@]+\.[^@]+$";
    System.Text.RegularExpressions.Regex regEx;
    System.Text.RegularExpressions.Match regMatch;
    str email;
    List emailAddresses;
    ListEnumerator enum;
    boolean retVal;
    regEx = new System.Text.RegularExpressions.Regex(emailAddressFilter);
    emailAddresses = SysEmailDistributor::splitEmail(_email);
    enum = emailAddresses.getEnumerator();
    while(enum.moveNext())
    {
        email = enum.current();
        if (email)
        {
            regMatch = regEx.Match(email);
            retVal = regMatch.get_Success();
        }
        else
            retVal = false;
        if(!retVal)
            break;
    }
    return retVal;
}

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...