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

Community site session details

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

End date should be greater than start date

(0) ShareShare
ReportReport
Posted on by 390

Hey team,

I want that my end date should be greater than start date.

this is the code which I had written in validatewrire() method of table but this code also gives the error message even if the end date is greater than start date. Please can you tell me what is wrong with my code?

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

return ret;
}

Also Please can you tell me, On the end date calendar how can we disable on all dates on the form before the start date or today's date.

My form has fields: First Name,Last name, Email,StartDate, EndDate

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    236,353 Most Valuable Professional on at
    RE: End date should be greater than start date

    Please use Insert > Insert Code (in the rich formatting view) to paste source code. It preserves indentation, making code easier to read.

    Like this:

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

    The problem is that you're using trans variable, but you never put any value to it, therefore all fields have their default values. Then you fail the validation if the dates are the same, which will always be the case if both have the default value.

    Use this variable instead (it refers to the object of the instance method).

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

  • skd Profile Picture
    390 on at
    RE: End date should be greater than start date

    Hey Martin Dráb,

    Thank you. Also Please can you tell me, On the end date calendar how can we disable  all dates on the form before the start date or today's date.

    My form has fields: First Name,Last name, Email,StartDate, EndDate

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: End date should be greater than start date

    What do you mean by "Date calendar"?

  • Suggested answer
    Vipin J Profile Picture
    1,603 on at
    RE: End date should be greater than start date

    Refer here

    How to validate end date to be greater than start date

  • Martin Dráb Profile Picture
    236,353 Most Valuable Professional on at
    RE: End date should be greater than start date

    Hi Vipin, your code doesn't seem to be related to record validations. It's not even X++.

    I see you started posting more replies just with links to your blog. If their intention is to merely promote your blog and not to answer questions, they'll be deleted as spam.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,028

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 579 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans