Dynamics AX Blog - Dynamics AX 2012 - Page 22

These posts are machine-translated.
Currently, only posts are displayed, which are relevant for Dynamics AX version »Dynamics AX 2012« Filter entfernen

RSS-Feed of this version

AX 2012: Selecting the values of a financial dimension

The following job demonstrates how to display the values of a financial dimension - in the example Department - via X++.

static void getValues4Dimension(Args _args)
{
    DimensionValueService dimensionValueService;
    DimensionContract dimensionContract;
    List dimensionValueContractList;
    ListEnumerator listEnumerator ;
    DimensionValueContract dimensionValueContract;
    DimensionValue dimensionValue;

    dimensionValueService = new DimensionValueService();
    dimensionContract = new DimensionContract();
    dimensionContract.parmDimensionName('Department');
    dimensionValueContractList = dimensionValueService.getDimensionValues(dimensionContract);
    listEnumerator = dimensionValueContractList.getEnumerator();

    setPrefix(strFmt("Dimension %1: ", dimensionContract.parmDimensionName()));
    while(listEnumerator.moveNext())
    {
        dimensionValueContract = listEnumerator.current();
        dimensionValue = dimensionValueContract.parmValue();

        info(dimensionValue);
    }
}

 
 

Tip: Convert job into class

Did you know that you can easily convert a job to a class simply by copying the job to classes-node in AOT using drag & drop?


 
 

Move pallet using X++

Using the following code, you will be able to move a pallet per code.

WMSPalletMove wmsPalletMove = new wmsPalletMove();
wmsPalletMove.parmWMSPalletId('00000022_117');
wmsPalletMove.parmToInventLocationId('300');
wmsPalletMove.parmToLocationId('01');
if(wmsPalletMove.validate())
{
   wmsPalletMove.run();
}

 


 
 

What is the difference between update and doUpdate?

What is the difference between update() and doUpdate()? You canfind the answer on MSDN or you take a look at the following table.

Method Note
insert vs. doInsert When raisng the doInsert the insert-method of the table will not be called
delete vs. doDelete When using the doDelete method the delete method of the table will not be called, but the delete-method of the xRecord will be called, therefore DeleteActions will work
update vs. doUpdate When raisng the doUpdate the update-method of the table will not be called

 


 
 

Working with the calling object of a form (Caller)

The following method contains some snippets that can be used to call various functions/methods of the calling object (form).

If you change element.args() to e.g. _args and pass the arguments to the method, you can use the code within a class as well.

void workWithCallingRecord()
{
    common          common;
    object          object;
    formDataSource  formDataSource;
    formRun         formRun;
    inventDim       inventDim;
    salesTable      salesTable;
    int             i;
    ;
    // Call method from calling record
    if( element.args() &&
        element.args().record() )
    {
        common = element.args().record();
        if(common.isFormDataSource())
        {
            info(tableId2Name(common.TableId));
            if(formDataSourceHasMethod(common.dataSource(), identifierStr("someMethod")))
            {
                object = common.dataSource();
                object.someMethod();
            }
        }
    }
 

    // Call method from calling form
    if(element.args() && element.args().caller() && element.args().caller().handle() == className2Id('formRun'))
    {
        formRun = element.args().caller();
        if(sysFormRun::hasMethod(formRun, identifierStr("someFormMethod")))
        {
            object = formRun;
            object.someFormMethod();
        }
    }

    // Get value from calling record
    if( element.args() &&
        element.args().record() )
    {
        common = element.args().record();
        if(common.TableId == tableNum(salesTable))
        {
            info(common.(fieldNum(salesTable, salesId)));
        }
    }

    // Get value from calling datasource (form with multiple datasources)
    if(element.args() && element.args().caller() && element.args().caller().handle() == className2Id('formRun'))
    {
        formRun = element.args().caller();
        for (i = 0; i <= formRun.dataSourceCount(); i++)
        {
            formDataSource = formRun.datasource(i);
            if (formDataSource && formDataSource.table() == tablenum(inventDim))    // Search for specific table
            {
                inventDim = formDataSource.cursor();
                break;
            }
        }
        if(inventDim)
        {
            info(inventDim.InventLocationId);
        }
    }

    // Change data in calling datasource
    if(element.args() && element.args().caller() && element.args().caller().handle() == className2Id('formRun'))
    {
        formRun = element.args().caller();
        for (i = 0; i <= formRun.dataSourceCount(); i++)
        {
            formDataSource = formRun.datasource(i);
            if (formDataSource && formDataSource.table() == tablenum(salesTable))    // Search for specific table
            {
                salesTable = formDataSource.cursor();
                break;
            }
        }
        if(salesTable)
        {
            // Update data
            salesTable.PurchOrderFormNum = "Some value";
            salesTable.update();
        }
    }

    // Refresh calling datasource
    if( element.args() &&
        element.args().record() )
    {
        common = element.args().record();
        if(common.isFormDataSource())
        {
            formDataSource = common.dataSource();
            formDataSource.research(true);
        }
    }
}

 
 

Dynamics AX: Illegal property value

If you try to change the AllowDuplicates-Property of a table index from No to Yes, the following error message may occur:

Illegal property value

In this case, presumably, the affected index is registered as PrimaryIndex or ClusteredIndex of the table.


 
 
Pages « 1 ... 19 20 21 22 

 

 
 
 
Posts of the actual month
März 2024
MoTuWeThFrSaSu
 123
45678910
11121314151617
18192021222324
25262728293031
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.