Dynamics AX 2012 x++ Enhancement, Now variables can be used in Selects

I have found the interesting enhancement in X++ Language. Now you can use the variables in the selects. scenario is that suppose you trying to copying bulk records in a table and one of the column you wanted is constant. like below i am trying to insert Fiscal periods records for a Ledger where record id of the ledger is Constant, so i took that in a variable and i am using it in the select.

RecId _ledgerRecId = Ledger::Current();

insert_recordset ledgerFiscalCalendarPeriod

(

Ledger,

FiscalCalendarPeriod,

Status

)

select _ledgerRecId, RecId, status

from fiscalCalendarPeriod;

Advertisements

2 Responses to Dynamics AX 2012 x++ Enhancement, Now variables can be used in Selects

  1. Hi Amir,

    I had tried writing a similiar query and passing variable but i get the error stating “The table ‘CustTable’ does not contain the field _num”

    Code:
    static void usageVariableinSelect()
    {
    AccountNum _num = ‘1101’;
    CustTable table;

    select _num, RecId from table;

    if (_num = table.AccountNum)
    {
    info(“Say Hello Variable to AX2012”);
    }
    }

    Can you please let me how could you successfully execute the code base given in ur article?

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: