✏️ Explanatory Question

Adding multiple conditions with the combination of OR & AND conditions in dynamic query range using X++

👁 1 Views
📘 Detailed Answer
🟢 Easy
1
Total Views
4
Related Qs
0%
Progress
💡

Answer with Explanation


	
Query query = new Query();

QueryBuildDataSource qbdsItemLookup;
qbdsItemLookup = query.addDataSource(tableNum(PurchReqLookup));

str filterString = strFmt('((%1.%2 == "%4") || (%1.%3 == %5) || ((%1.%3 != %5) && (%1.%6 == %5)))'
                            , qbdsItemLookup.name()
                            , fieldStr(PurchReqLookup, userId)
                            , fieldStr(PurchReqLookup, GroupId)
                            , SysQueryRangeUtil::currentUserId()
                            , SysQueryRangeUtil::valueEmptyString()
                            , fieldStr(PurchReqLookup, UserId)
                            );
 
qbdsItemLookup.addRange(fieldNum(PurchReqLookup, RecId)).value(filterString);