Skip to main content

Notifications

How to apply custom range on AOT query in D365 Finance and Operations

Hi All,

Here in this blog will see how to apply custom range on AOT query.

Requirement: Add range on AOT query to get the records created before given days (createdDateTime - PriorDays)
Steps 1 - Add new field in the parameters. Please refer below screen shot.


Step 2 - Create new class and use attribute for range method. Refer below screen shot.
internal final class TestQueryRangeUtil
{
 
  [QueryRangeFunctionAttribute()]
  public static str greaterThanDateByParameter()
  {
        int relativeDays = SalesParameters::find().TestPriorDays;
        utcdatetime currentDateTime;

        currentDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(),      DateTimeUtil::getUserPreferredTimeZone());

        return '> '   SysQueryRangeUtil::value(DateTimeUtil::date(DateTimeUtil::addDays(currentDateTime,relativeDays)));
  }

}

Step 3:Create range on AOT query and add below given expression as value.

(TESTQueryRangeUtil::greaterThanDateByParameter())



Thats it. Happy Coding.

This was originally posted here.

Comments

*This post is locked for comments