Make a lookup for the Queries

Like all method in Global class (like pickTable)

There is the code for make the same list BUT for the queries.

static str pickQuery()
{
    #ResAppl
    #AOT

    int             i;
    int             nodeCount;
    str             nameStr;
    container       names;

    Object          formRun;

    TreeNode        node;
    TreeNode        child;
    ;

    node        = TreeNode::findNode(#QueriesPath);
    nodeCount   = node.AOTchildNodeCount();
    child       = node.AOTfirstChild();

    formRun     = classfactory.createPicklist();
    formRun.init();

    for (i = 1; i <= nodeCount; i++)
    {
        names  += child.AOTgetProperty("Name");
        child   = child.AOTnextSibling();
    }

    formRun.choices(names, #ImageQuery);
    formRun.caption("@SYS26727");
    formRun.run();
    formRun.wait();

    if (formRun.choice())
    {
        return formRun.choice();
    }

    return '';
}
Advertisements

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; 
}