Sample X++ code that you can use to disable or to hide a query range in Microsoft Axapta

Article ID: 910958
Microsoft Business Solutions-Axapta 3.0 is now part of Microsoft Dynamics AX 3.0. All references to Microsoft Business Solutions-Axapta and Microsoft Axapta pertain to Microsoft Dynamics AX.
Expand all | Collapse all

INTRODUCTION

This article contains sample X++ code that you can use to disable or to hide a query range in Microsoft Business Solutions - Axapta 3.0.

MORE INFORMATION

The following code sample shows how to use X++ code to create a query that contains three ranges. In the code sample, only one specified range can be changed by the end user. In the code sample, the following conditions are true:
  • The first range is not shown.
  • The second range is shown but cannot be edited.
  • The third range can obtain the input from the end user.
static void QueryStatusTest(Args _args)
{
    Query                   q;
    Queryrun                qr;
    QueryBuildRange         qbr,qbr1,qbr2;
    QueryBuildDataSource    qbds;
    VendTable               vt;
    ;

    // Create an instance of the query class and then provide a name of "Vendors."
    q = new query("Vendors");

    // Create a data source that connects to the VendTable table.
    qbds = q.addDataSource(tablenum(VendTable));

    // Use three different field names to create three ranges.
    qbr  = qbds.addRange(fieldnum(VendTable,AccountNum));
    qbr1 = qbds.addRange(fieldnum(VendTable,Blocked));
    qbr2 = qbds.addRange(fieldnum(VendTable,Name));

    // Set the values for the three ranges.
    qbr.value('3*');
    qbr1.value(strfmt('(%1 == %2)',fieldstr(VendTable,Blocked),any2int(CustVendorBlocked::No)));
    qbr2.value('Office World');
    
    // Set the status of each range.
    qbr.status(1);
    qbr1.status(2);
    qbr2.status(0);

    // Create an instance of the QueryRun class.
    qr = new QueryRun(q);

    // Verify that the QueryRun form is active, and then parse the tablenum value through the VendTable table.
    If (qr.prompt())
    {
        while (qr.next())
        {
            vt = qr.get(tablenum(VendTable));
            print vt;
        }
        pause;
    }

    // Show the SQL statement that is produced by the query.
    info (qr.query().dataSourceNo(1).toString());

}
Note The status method provides the function for each range.

Properties

Article ID: 910958 - Last Review: July 26, 2011 - Revision: 2.0
Keywords: 
kbinfo kbmbsmigrate KB910958

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com