Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    Koen Roks Profile Picture
    on at
    RE: Typical use of QuerybuildRange

    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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans