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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Typical use of QuerybuildRange

(0) ShareShare
ReportReport
Posted on by

HI all,

I have an issue in using QueryBuildRange. I need to apply date range in query build Range expression.

As you can see below I want to add No of Days( Integer) in TransDate field of Datasource  in the range expression itself. I really need to know how can I achieve this as with the existing code because it is concatenating rather than adding ( i.e it is accepting as a string in strfmt).

Can you please suggest a standard approach?

queryBuildDataSource = query.addDataSource(tableNum(ABC));

queryBuildRange = queryBuildDataSource.addRange(fieldnum(ABC, XYZ));

 

queryBuildRange.value(strFmt('((%1 == %2) || ((%1 == %3)))',

fieldStr(ABC, XYZ),

any2int(XYZ::Delivered),

any2int(XYZ::ToBeReturned)));

*/

GracePeriod = CustParameters::find().DEFTable;   // Integer value(No of days)

queryBuildRange.value(strFmt('(((%1 == %2) && (%4 <= %5)) || ((%1 == %3) && ((%4+%6) <= %5)))',

fieldStr(ABC, iop),

any2int(XYZ::Delivered),

any2int(XYZ::ToBeReturned),

fieldStr(ABC,Transdate) ,

date2StrXpp(latestDueDate),

any2date(GracePeriod)));

queryBuildRange.toString();

info(queryBuildRange.toString());

 

queryBuildRange.status(RangeStatus::Locked);

chooseLines = new QueryRun(query);

 

 

Thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Koen Roks Profile Picture
    on at

    Hi Deepak

    To create the range you can use the SysQuery::Range method (https://msdn.microsoft.com/en-us/library/sysquery.range.aspx)

    To add the days I would suggest ussing the DateTimeUtil::addDays method

    utcDateTime now = DateTimeUtil::getSystemDateTime();

    qbds.addRange(fieldNum(Table, StartDate))
            .value(SysQuery::range(now, DateTimeUtill::addDays(now, GracePeriod));


    Regards,

    Koen

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans