Announcements
No record found.
Hi,
If I have a start date time and end date time, would like to get the active HCMEmployment record during that date range in Query, how can I write it in X++?
Thanks,
*This post is locked for comments
You can refer to : Valid Time State Tables and Date Effective Data usage at msdn.microsoft.com/.../gg861781.aspx.
Your query should look something like this:
select validTimeState(validFrom, validTo) . . .
from HcmEmployment . . .
Kind Regards,
István
You can simply google it, the first link gives you the answer.
To quote the example from Microsoft Library.
static void VtsJob1(Args _args) { // A VTS table in AX 2012. CustPackingSlipTransHistory xrec1; utcDateTime myDateFrom , myDateTo; anytype myAnytype = -1; myDateFrom = DateTimeUtil::utcNow(); myDateTo = myDateFrom; SELECT validTimeState(myDateFrom, myDateTo) * FROM xrec1; myAnytype = xrec1.getFieldValue("RecId"); info(myAnytype); }
Thanks István,
But I am using Query, QueryRun and QueryBuildRange, not pure X++ statement.
thanks,
Here is how you can use Query with ValidTimeState tables. Microsoft library pages also gives you an example.
For better understanding of this framework, download the Whitepaper Using_Date_Effective_Patterns_AX2012.pdf from www.microsoft.com/.../details.aspx.
You can use a similar solution to this:
qry = new Query();
....
qry.validTimeStateDateTimeRange(validFrom, validTo);
Regards,
Not forget validTimeStateUpdate :
logisticsPostalAddressHeader_ds.validTimeStateUpdate(ValidTimeStateUpdate::Correction);
logisticsPostalAddressHeader_ds.query().validTimeStateDateTimeRange(DateTimeUtil::minValue(), DateTimeUtil::maxValue());
Regards
Hassan
Hi Yuji,
you can use SysQuery::Range(), below is the example code:
TransDate dateFrom; TransDate dateTo; Query qry = new Query(); QueryBuildDataSource qbds1; ; ... ... qbds1.addRange(fieldNum(myTable,myField)).value(SysQuery::Range(dateFrom, dateTo));
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.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Basit 1
GL-01081504-0 1
Roya 1