Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use AND/OR operators when building query in ax 2012 x++
    primarykey
    data
    text
    <p>I couldn't really find anything about this, and i couldn't really figure it out. Anyways, I have created a view which i need to filter using query/QueryRun etc. in x++.</p> <p>The select statement for what i am trying to do looks like this</p> <pre><code> while select salestable order by PtsWebDeliveryDate, salesId where (SalesTable.SalesStatus == SalesStatus::Delivered &amp;&amp; !SalesTable.PtsProdNorwood &amp;&amp; SalesTable.CustAccount != acc &amp;&amp; SalesTable.InvoiceAccount != acc &amp;&amp; salestable.PtsWebDeliveryDate &gt;= today() &amp;&amp; salestable.PtsWebDeliveryDate &lt;= today()+daysahead) || ( SalesTable.SalesStatus == SalesStatus::Backorder &amp;&amp; SalesTable.SalesType == SalesType::Sales &amp;&amp; !SalesTable.PtsProdNorwood &amp;&amp; SalesTable.CustAccount != acc &amp;&amp; SalesTable.InvoiceAccount != acc &amp;&amp; ( (salesTable.PtsSalesorderPacked &amp;&amp; salestable.PtsWebDeliveryDate &gt;= today() &amp;&amp; salestable.PtsWebDeliveryDate &lt;= today()+daysAhead) || (!salesTable.PtsSalesorderPacked &amp;&amp; salestable.PtsWebDeliveryDate &gt;= d &amp;&amp; salestable.PtsWebDeliveryDate &lt;= today()+daysahead)) ) { //Do stuff } </code></pre> <p>As you can see i have som OR operators which i need to use. i have startet building the query in x++ and this is what i got:</p> <pre><code>q = new Query(); q.addDataSource(TableNum("packlistview")); q.dataSourceNo(1).addSortField(fn[_OrderBy], _direction); q.dataSourceNo(1).addRange(fieldNum(PackListView, SalesStatus)).value(queryValue(SalesStatus::Delivered)); q.dataSourceNo(1).addRange(fieldNum(PackListView, PtsProdnorwood)).value(queryValue(NoYes::No)); q.dataSourceNo(1).addRange(fieldNum(PackListView, CustAccount)).value(queryValue(!acc)); q.dataSourceNo(1).addRange(fieldNum(PackListView, PtsWebDeliveryDate)).value(queryrange(today(),today()+daysahead)); //OR q.dataSourceNo(1).addRange(fieldNum(PackListView, SalesStatus)).value(queryValue(SalesStatus::Backorder)); q.dataSourceNo(1).addRange(fieldNum(PackListView, SalesType)).value(queryValue(SalesType::Sales)); q.dataSourceNo(1).addRange(fieldNum(PackListView, PtsProdnorwood)).value(queryValue(false)); q.dataSourceNo(1).addRange(fieldNum(PackListView, CustAccount)).value(queryValue(!acc)); q.dataSourceNo(1).addRange(fieldNum(PackListView, InvoiceAccount)).value(queryValue(!acc)); q.dataSourceNo(1).addRange(fieldNum(PackListView, PtsSalesorderPacked)).value(queryValue(false)); q.dataSourceNo(1).addRange(fieldNum(PackListView, PtsWebDeliveryDate)).value(queryrange(d, today()+daysahead)); //OR q.dataSourceNo(1).addRange(fieldNum(PackListView, PtsSalesorderPacked)).value(queryValue(false)); q.dataSourceNo(1).addRange(fieldNum(PackListView, PtsWebDeliveryDate)).value(queryrange(d, today()+daysahead)); qr = new queryRun(q); while( qr.next())// &amp;&amp; counter &lt; 100 { //Do stuff } </code></pre> <p>So how do I do incorporate the OR operators with this? </p> <p>Cheers guys :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload