Dynamics AX Blog - Dynamics AX 2012 - Page 22

RSS-Feed of this version
Tip: Convert job into classDid 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.
| ||||||||
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 valueIf 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. |
|
|
|
|
|
|
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); } }