Make an OR in a query

Simple select query in Ax Client:

static void projTableJob(Args _args)
{
    ProjTable   projTable;
    ;
 
    while Select projTable where projTable.ProjId Like "305492-00*" ||
                                 projTable.Name   Like "305492-00*"
 
    {
        print projTable.Name;
    }
 
    pause;
}

Using Query Classes in Ax Client: The same query is implemented by using Query classes in Ax client

static void projTableJobUsingQuery(Args _args)
{
    Query                   query;
    QueryBuildDataSource    qb, qb1;
    QueryBuildRange         qbr, qbr1;
    QueryRun                qr;
    ProjTable               projTable;
    str                     myvalue = '305492-00*';
    ;
 
    query = new Query();
    qb = query.addDataSource(tablenum(ProjTable), "ProjTable");
 
    qbr = qb.addRange(fieldnum(ProjTable, ProjId));
// Here the OR condition is implemented.   
    qbr.value(strfmt('(%1.%2 Like "%3") || (%1.%4 Like "%5")',
                qb.name(),
                fieldstr(ProjTable, ProjId), any2str(myvalue),
                fieldstr(ProjTable, Name),  any2str(myvalue)
                ));
 
 
    qr = new QueryRun(query);
 
    while (qr.next())
    {
        projTable = qr.get(tablenum(ProjTable));
        print projtable.Name;
    }
 
    pause; 
}
Advertisements