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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to write OR Expressions in Query Ranges in AX 2012

(0) ShareShare
ReportReport
Posted on by 692

Hi Dax Techies,

I wrote below code in list page interaction class initilizeQuery() Method.

HcmWorkerRecId          hcmWorkerRecId   = Global::currentWorker();

if (hcmWorkerRecId && this.listPage().listPageArgs().menuItemName() == menuitemDisplayStr(LeaveApplicationDateOfReturnListPage))
{
qbds = _query.dataSourceTable(tableNum(HcmEmploymentLeave));
qbds.name("HcmEmploymentLeave");
qbds.addRange(fieldNum(HcmEmploymentLeave, Worker)).value(
strFmt('((%1.%2 == "%4") || (%1.%3 == "%4"))',
qbds.name(),
fieldStr(HcmEmploymentLeave, Worker),
fieldStr(HcmEmploymentLeave, Approver),
HcmWorkerRecId));

}

but my above expression is not at all working but when i build the same query using a job it is giving correct string like below 

SELECT * FROM HcmEmploymentLeave(HcmEmploymentLeave) WHERE ((((HcmEmploymentLeave.Worker == "5637157327") || (HcmEmploymentLeave.Approver == "5637157327"))))

Below two ranges how can i frame using OR expression 

HcmWorkerRecId          hcmWorkerRecId   = Global::currentWorker();

qbds.addRange(fieldNum(HcmEmploymentLeave,Worker)).value(int642str(hcmWorkerRecId ));

qbds.addRange(fieldNum(HcmEmploymentLeave,Approver)).value(int642str(hcmWorkerRecId));

can anybody help me.

Thanks,

Krishna

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,978 Most Valuable Professional on at

    You can see the problem in your SQL code. Worker == "5637157327" would work if RecId was a string, but it's a number, therefore you shouldn't use quotations there.

  • gsbsrk b Profile Picture
    692 on at

    Thank you so much Martin

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans