Tuesday, March 5, 2019

Dynamic Query in X++

// The first step is to define the query variables that we will be using. This is building the framework.
    Query                                q;
    QueryRun                         qr;
    QueryBuildDataSource    qbds;
    QueryBuildRange             qbr;
    PurchTable                        purchTable;

// Instantiates or creates the query framework.
    q       = new Query();

// Links the table to the data source definition.
    qbds    = q.addDataSource(tableNum(PurchTable));

//Set the Range and Range value
    qbr     = qbds.addRange(fieldNum(PurchTable, PurchId));

//Instantiate the query
    qr      = new QueryRun(q);
//Query will display a query form for the user. The user can then add their own number sequences or sorting preferences. This is ideal to create much more dynamic queries for form information or reporting.


//The while loops over the Table in search of the information needed.
            purchTable = qr.get(tableNum(PurchTable));
            info(strfmt("%1 - %2",PurchTable.PurchId,PurchTable.PurchName));

1 comment:

  1. Thanks for sharing this informative content , Great work
    Leanpitch provides online training in Enterprise agile coaching during this lockdown period everyone can use it wisely.
    Enterprise agile coaching


How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// &l...