Announcements
query buildQuery() { QueryBuildDataSource qbdsDistributorWorkerTarget,qbdsOAE1PSRHierarchy; Query query = new Query(queryStr(OABCustomerReportLookupDetail)); qbdsDistributorWorkerTarget = query.dataSourceTable(tableNum(OAE1DistributorWorkerTarget)); qbdsOAE1PSRHierarchy = query.dataSourceTable(tableNum(OAE1PSRHierarchy)); qbdsDistributorWorkerTarget.addRange(fieldNum(OAE1DistributorWorkerTarget, ModifiedDateTime)).value(queryRange(fromDate,toDate)); //Employee Code Employee = con2Str(EmployeeCon); if(Employee) { Employee = strReplace(Employee,';',','); qbdsOAE1PSRHierarchy.addRange(fieldNum(OAE1PSRHierarchy, ASM)).value(Employee) ; qbdsOAE1PSRHierarchy.addRange(fieldNum(OAE1PSRHierarchy, PSRSalesman)).value(Employee); qbdsOAE1PSRHierarchy.addRange(fieldNum(OAE1PSRHierarchy, OABSalesExecutivecode)).value(Employee); } return query; }
I have added my query, now under if condition there are three ranges as of now I have passed, but I want if any of condition is true, query range work , now it works only when all three ranges are simultaneously passed
Thankyou so much for helping !!
Can you try below code
Employee = strReplace(Employee,';',','); qbdsOAE1PSRHierarchy.addRange(fieldNum(OAE1PSRHierarchy, ASM)).value( strFmt('((%1.%2 == "%5") || (%1.%3 == "%5")) || (%1.%4 == "%5"))', qbdsOAE1PSRHierarchy.name(), fieldStr(OAE1PSRHierarchy, ASM), fieldStr(OAE1PSRHierarchy, PSRSalesman), fieldStr(OAE1PSRHierarchy, OABSalesExecutivecode), Employee));
Check this old thread
community.dynamics.com/.../how-to-add-range-on-multiple-field-with-same-value
qbdsOAE1PSRHierarchy.addRange(fieldNum(OAE1PSRHierarchy, RecId)).value('(OAE1PSRHierarchy.ASM == ' Employee ' || OAE1PSRHierarchy.PSRSalesman == ' Employee ' || OAE1PSRHierarchy.OABSalesExecutivecode == ' Employee ')');
this range is not working
Please share your code that you wrote after going through above suggestions.
its not returning expected output
Hi Sachin, Please check this article
To use an OR on different fields, you need to use "Expressions in query ranges", have a look at the link below. Also search for "Expressions in query ranges" for more information.
Hi Sachin,
You can use an or statement by using an advanced query expression on e.g. the RecId field. See next example:
qbdsOAE1PSRHierarchy.addRange(fieldNum(OAE1PSRHierarchy, RecId)).value( '(OAE1PSRHierarchy.ASM == ' Employee ' || OAE1PSRHierarchy.PSRSalesman == ' Employee ' ' || OAE1PSRHierarchy.OABSalesExecutivecode == ' Employee ')';
André Arnaud de Cal...
294,110
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator