How to add select button for query form on a class




public class CreateDialog extends RunBaseBatch
{
    DialogField dialoginventTablet;
    InventTable inventTable; 
    QueryRun queryRun;
    #define.CurrentVersion(1)
    #define.version(1)
    #localmacro.CurrentList
    inventTable
     #endmacro
}
To initilaize the queryRun object, override the initParmDefault method.
public void initParmDefault()
{
    Query query;
    QueryBuildDataSource    qbd;
    QueryBuildRange     qbr;
    super();
    query = new Query();
    qbd = query.addDataSource(tableNum(InventTable));
    qbr = qbd.addRange(fieldNum(InventTable, ItemId));
    queryRun = new QueryRun(query);
}
Pack and unpack method is must to save the state of queryRun.
PACK : 

public container pack()
{  return [#CurrentVersion, #CurrentList, queryRun.pack()];}
UNPACK:
public boolean unpack(container _packedClass)
{
Version version = runbase::getVersion(_packedClass);
Container packedQuery;
switch (version)
{
    case #CurrentVersion:
        [version, #CurrentList, packedQuery] = _packedClass;
     if (packedQuery)
        queryRun = new QueryRun(packedQuery);
    break;
     default:
        return false;
    }
    return true;
}
To make the QueryRun object available for presentation in the dialog box, override the queryRun method to return QueryRun object.

public QueryRun queryRun()
{
     return queryRun;
}

To show the query in the dialog box, you must override the showQueryValues method to return the value true.

boolean showQueryValues()
{
    return true;
}
public static void main (Args _args)
{
     CreateDialog obj;
     obj = new CreateDialog ();
     if(obj.prompt())
          obj.run();
}
public void run()
{
 
     inventTable = inventTable::find(ItemId);
     ttsbegin;
     if(inventTable)
     {
          //shows retrieved information
          Info();
     }
     else
     {
          rrror();        
     }
     ttsCommit;
}       

If you open the class, you can see that the query is embedded in the dialog box.

Comments

Popular posts from this blog

Exporting AX Data to .csv File Through Class (Dialog)

Export Model Store (AXUtil) - ax 2012