how to give a select button on a dialog

Hi

how to add a  select button on a dialog using classes, when i click on the select button it should open a query , where i can select the range...

  • Hi Shiva,

    Build a query in the QueryNode of the AOT by using the required tables....Let say for example,created a query "EmployeeData" in the query node using the "EmplTable" as datasource in the query...

    And use this query in the class level by writing the following methods...

    public QueryRun queryRun()
    {
        return queryRun;
    }

    public void new()
    {
    ;
        super();
        queryRun = new QueryRun(querystr(EmployeeData));
    }
    For more detailed you can check the exisitng class in the AX HRMAbsenceCreateTables.By this you can acheive it...

  • Hi Shiva,

    To add a select button on the dialog form to specify a query range on a field (For ex. CustAccount) you will have to create an instance of QueryRun class in the class declaration method of your class as shown in the below example:

    public class BikeTuningOffers extends RunBase

    {

    DialogField dialogCreateServiceOrders;

    NoYesId createServiceOrders;

    CustAccount custAccount; 

    QueryRun queryRun;

     

    #define.CurrentVersion(1)

    #define.version(1)

    #localmacro.CurrentList

    createServiceOrders

    #endmacro

    }

    Then to initialize the QueryRun object, override the initParmDefault method, as shown in the following code. This method is called by the RunBase framework if no saved object state is found by the SysLastValue framework via the unpack method.

    public void initParmDefault()

    {

    Query query;

    ;

        super();

        query = new Query();

        query.addDataSource(tableNum(CustTable));

        queryRun = new QueryRun(query);

    }

    You must modify the pack method, as shown in the following example, so that you can save the state of the QueryRun object.

    public container pack()

    {

    ;

        return [#CurrentVersion, #CurrentList, queryRun.pack()];

    }

     

    Consequently, you must also modify the unpack method to reinstantiate the QueryRun object, as shown here.

    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 your QueryRun object, as shown in the following code.
    public QueryRun queryRun()
    {
    ;
    return queryRun;
    }
    To show the query in the dialog box, you must override the showQueryValues method to
    return the value true, as follows.
    boolean showQueryValues()
    {
    ;
    return true;
    }
    If you open the class now, you can see that the query is embedded in the dialog box. Finally you have to use the queryRun object in your business logic method to retrieve the values defined in the dialog box query.
    Regards,
    Shankar

Related
Recommended