Home > Ax Technical > Exists methods don’t need table declaration in Dynamics Ax

Exists methods don’t need table declaration in Dynamics Ax

Do you know when we use select statement for conditional checks, we don’t need to declare a variable if we use the same name as the table. Look at the example below to understand better.

static boolean SelectStatementInBooleanConditions()
{
    //no declaration for table object has been made.
    boolean test;
    ;

    //testing a variable
    test =  (select firstonly salesTable).salesId ? true : false;

    //if condition
    if ((select firstonly salesTable).recid)
    {
        return true;
    }

    //switch statement
    switch ((select firstonly salesTable).recid)
    {
        case 0:
            return true;
        case 1:
            return false;
        default:
            return false;
    }

    //return statement
    return ((select firstonly salesTable).recid);
}

In standard you can find similar usage extensively in exists methods. This can make your code smarter and simpler 😉

Run the job and see that you dont get any errors……

Advertisements
  1. July 15, 2010 at 2:49 pm

    not really it works even in Normal methods..

  2. Eric Fisher
    July 15, 2010 at 2:28 pm

    I believe this will only work in static methods.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: