in a form i have 2 fields in a grid 1. Start date time and 2. End date time
Start date time End date time
say when some one enters startdatetime as 14 march 2015 and end date time as 18 march 2015
and next time when they enters strat date time as 15 march 2015 then it should throw a error message any idea how to compare this two date time fields and check all the exsiting vaulues in it.
basically it should throw throw error message as 15 march 2015 is already there between 14 march 2015 and 18 march 2015
It’s not clear what problem you have with comparing fields.
Unfortunately you didn’t add a tag with your version of AX; if you use AX 2012, you can do it without any code (see Valid Time State Tables and Date Effective Data).
public boolean validateWrite()
ret = super();
startdatetime1 = this.Startdatetime;
while select Startdatetime from TestValidation
while select Startdatetime from TestValidation where TestValidation.Startdatetime <= startdatetime1
&& TestValidation.Enddatetime >= startdatetime1
throw error(“entered start date falls between the previous records”);
enddatetime1 = this.Enddatetime;
while select Enddatetime from TestValidation
while select Enddatetime from TestValidation where TestValidation.Startdatetime <= enddatetime1
&& TestValidation.Enddatetime >= enddatetime1
throw error("entered end date falls between the previous records ");