web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Validate mandatory fields

(0) ShareShare
ReportReport
Posted on by 390

Hey Team,

I have a table with fields "First Name","Last Name","Start date", "End date", Email.

Out of these fields  "First Name","Last Name","Start date","Email" are mandatory fields. 

i want to validatewrite() on both StartDate and Email 

My validatewrite() method has the logic "End date" should be greater than "Start Date". My code:

 public boolean validateWrite()
    {
        boolean ret;
        ret = super();
        if(this.EndDate)
        {
            if(this.EndDate<=this.StartDate)
            {
                ret = ret && checkFailed("End Date should be greater then Start Date");
            }
        }

      

I even want to validate the email address field so how can I write both the piece of code in validatewrite(). My code for email validation:

            TransformationAssociates eda;
            Str     MatchEmailPattern =@"\b[a-zA-Z0-9._% -] @[a-zA-Z0-9.-] \.[a-zA-Z]{2,4}\b";
            System.Text.RegularExpressions.Match myMatch;
            myMatch = System.Text.RegularExpressions.Regex::Match(eda.Email, MatchEmailPattern);
                 if (myMatch.get_Success())
             info(strFmt("%1 is an valid email id ", eda.Email));
                 else
            Error(strFmt("%1 is not an valid email id ", eda.Email));

Please tell me how to validate both the fields?

I have the same question (0)
  • Verified answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi sdk,

    Just add the next validation block after EndDate validation block. I assume that regex is correct.

    if(this.EndDate)
    {
    	if(this.EndDate<=this.StartDate)
    	{
    		ret = ret && checkFailed("End Date should be greater then Start Date");
    	}
    }
    
    if (this.email)
    {
        Str     MatchEmailPattern =@"\b[a-zA-Z0-9._% -] @[a-zA-Z0-9.-] \.[a-zA-Z]{2,4}\b";
        System.Text.RegularExpressions.Match myMatch;
        
        myMatch = System.Text.RegularExpressions.Regex::Match(this.Email, MatchEmailPattern);
        
        if (!myMatch.get_Success())
        {
            ret = checkFailed(strFmt("%1 is not an valid email id ", this.Email));
        }
    }

  • Verified answer
    Blue Wang Profile Picture
    on at

    Hi Skd,

    Just use multiple if judgments,like this:

    0763.PNG

    or write multiple methods for different verifications, and then call in validateWrite().

  • skd Profile Picture
    390 on at

    Hey Sergei,

    Thank you so much

  • skd Profile Picture
    390 on at

    Hey Blue Wang,

    Thank you so much.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans