Here is the list of tools and resources available for developers working with the Dynamics AX 2012 Beta:
This blog is about daily challenges we normally faced in Dynamics 365 and Dynamics AX development.
Monday, April 18, 2011
Dynamics AX 2012 Hands on Labs
Here is the list of new enhancement made on Dynamics AX 2012 release:
Thats it !!!!!!!!!!!!!!!!!!
Thats it !!!!!!!!!!!!!!!!!!
Friday, April 15, 2011
Creating transfer order through X++ code
To create a transfer oder via a code:
inventTransferTable.clear();
inventTransferTable.initValue();
numberSequenceReference = InventParameters::numRefTransferId();
numberSeq =
numberSeq::newGetNumFromCode(numberSequenceReference.NumberSequence);
inventTransferTable.TransferId = numberSeq.num();
inventTransferTable.InventLocationIdFrom = fromloc;
inventTransferTable.modifiedField(fieldNum(InventTransferTable,InventLocationIdFrom));
inventTransferTable.InventLocationIdTo = toloc;
inventTransferTable.modifiedField(fieldNum(InventTransferTable,InventLocationIdTo));
inventTransferTable.TransferStatus = InventTransferStatus::Created;
inventTransferTable.insert();
inventTransferLine.clear();
inventTransferLine.initFromInventTransferTable(inventTransferTable,
NoYes::Yes);
nventTransferLine.ItemId = item;
inventTransferLine.initFromInventTable(InventTable::find(item));
inventTransferLine.QtyTransfer = qty_ship;
inventTransferLine.QtyShipNow = 0;
inventTransferLine.QtyReceiveNow = 0;
inventTransferLine.insert();
Also set the two fields:
QtyRemainShip and QtyRemainReceive to the value of QtyTransfer when you create the line.
inventTransferTable.clear();
inventTransferTable.initValue();
numberSequenceReference = InventParameters::numRefTransferId();
numberSeq =
numberSeq::newGetNumFromCode(numberSequenceReference.NumberSequence);
inventTransferTable.TransferId = numberSeq.num();
inventTransferTable.InventLocationIdFrom = fromloc;
inventTransferTable.modifiedField(fieldNum(InventTransferTable,InventLocationIdFrom));
inventTransferTable.InventLocationIdTo = toloc;
inventTransferTable.modifiedField(fieldNum(InventTransferTable,InventLocationIdTo));
inventTransferTable.TransferStatus = InventTransferStatus::Created;
inventTransferTable.insert();
inventTransferLine.clear();
inventTransferLine.initFromInventTransferTable(inventTransferTable,
NoYes::Yes);
nventTransferLine.ItemId = item;
inventTransferLine.initFromInventTable(InventTable::find(item));
inventTransferLine.QtyTransfer = qty_ship;
inventTransferLine.QtyShipNow = 0;
inventTransferLine.QtyReceiveNow = 0;
inventTransferLine.insert();
Also set the two fields:
QtyRemainShip and QtyRemainReceive to the value of QtyTransfer when you create the line.
Monday, April 11, 2011
Dynamics AX 2012 Developer papers is now available on MSDN
The developer documentation for Dynamics AX 2012 is now available on MSDN
Microsoft Dynamics AX 2012 Beta
Microsoft Dynamics AX 2012 Beta
Wednesday, April 6, 2011
Display all/specific AOT tables in a lookup
For displaying all/specific AOT objects like tables in the lookup control, we need to iterate the UtilidElements table with our desired criteria.
static void lookupAOTTables(FormStringControl _ctrl)
{
SysTableLookup sysTableLookup =
SysTableLookup::newParameters(tablenum(UtilidElements), _ctrl);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange nameQBR, typeQBR;
;
sysTableLookup.addLookupfield(fieldnum(UtilidElements, Name));
sysTableLookup.addLookupfield(fieldnum(UtilidElements, Id));
queryBuildDataSource = query.addDataSource(tablenum
(UtilidElements));
nameQBR = queryBuildDataSource.addRange(fieldnum(UtilidElements,
name));
nameQBR.value('Cust*');
typeQBR = queryBuildDataSource.addRange(fieldnum(UtilidElements, recordType));
typeQBR.value(SysQuery::value(UtilElementType::Table));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
static void lookupAOTTables(FormStringControl _ctrl)
{
SysTableLookup sysTableLookup =
SysTableLookup::newParameters(tablenum(UtilidElements), _ctrl);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange nameQBR, typeQBR;
;
sysTableLookup.addLookupfield(fieldnum(UtilidElements, Name));
sysTableLookup.addLookupfield(fieldnum(UtilidElements, Id));
queryBuildDataSource = query.addDataSource(tablenum
(UtilidElements));
nameQBR = queryBuildDataSource.addRange(fieldnum(UtilidElements,
name));
nameQBR.value('Cust*');
typeQBR = queryBuildDataSource.addRange(fieldnum(UtilidElements, recordType));
typeQBR.value(SysQuery::value(UtilElementType::Table));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Friday, April 1, 2011
Count total number of records
To count number of records in a query, you just need check it through SysQuery::countTotal(QueryRun) and if the query have more than one data sources use SysQuery::countLoops(QueryRun) instead of SysQuery::countTotal(QueryRun).
Happy Daxing
Tuesday, March 15, 2011
Error executing code: The method has been called with an invalid number of parameters
One of the great features of Dynamics AX is the rich integration with other applications or services. The Dynamics AX client is for example exchanging data with Microsoft Office applications like Microsoft Office Excel or Microsoft Office Outlook. Some of these interactions are performed using COM. When the Dynamics AX Client is using COM for the data exchange in certain situation it can happen you are getting confronted with one of the following error message:
Certain situations means, that you are not always getting this error message but only sometimes and the error is not reproducible. The chance of getting this error message is higher when you continue to work in other applications while the Dynamics AX client is performing the COM operation.
One reason for running into this issue can be if the Windows Operating System is replacing the Dynamics AX application window by a ghost window.
When Dynamics AX starts a lengthy COM operation, it is not responding to messages sent by the Windows Operating System in time. So Windows supposes Dynamics AX has stopped responding. When this happens the Dynamics AX application window is replaced by a ghost window until Dynamics AX resumes. Window ghosting is a nice feature that allows the user to minimize, move or close the main window even if the application is not responding. You can easily identify a ghost window as it shows (Not responding) in the window title.
Unfortunately the replacement of the Dynamics AX application window by the ghost window can interfere the COM operation and result in the above error message.
Therefore it can be helpful to turn window ghosting for the Dynamics AX Client off:
Here are the workarounds we know so far...
Workaround 1: Disable Window Ghosting as described in this post.
Workaround 2: Debug the X++ code down to the line that is causing the error. Once identified, insert one line before this statement a call to the yield method of the xInfo class.
Example: infolog.yield();
namespace = outlook.getNamespace(#mapidef);
Workaround 3: Debug the X++ code down to the line that is causing the error. Once identified, place the statement inside a try / catch block. In the catch block simply retry the operation.
Example: int retryCount = 3;
//...
try
{
namespace = outlook.getNamespace(#mapidef);
}
catch(Exception::Error)
{
retryCount--;
if(retryCount > 0)
retry;
else
throw(Exception::Error);
}
- Error executing code: The method has been called with an invalid number of parameters
- The number of arguments provided is different from the number of arguments accepted by the method
One reason for running into this issue can be if the Windows Operating System is replacing the Dynamics AX application window by a ghost window.
When Dynamics AX starts a lengthy COM operation, it is not responding to messages sent by the Windows Operating System in time. So Windows supposes Dynamics AX has stopped responding. When this happens the Dynamics AX application window is replaced by a ghost window until Dynamics AX resumes. Window ghosting is a nice feature that allows the user to minimize, move or close the main window even if the application is not responding. You can easily identify a ghost window as it shows (Not responding) in the window title.
Unfortunately the replacement of the Dynamics AX application window by the ghost window can interfere the COM operation and result in the above error message.
Therefore it can be helpful to turn window ghosting for the Dynamics AX Client off:
- Locate the Dynamics AX shortcut in the Windows Start Menu
- Click with the right mouse button on the shortcut and select Properties
- Go to the Compatibility tab
- Enable the checkbox Run this program in Compatibility mode for and select Windows XP (Service Pack 2)
- We have seen this issue most on Windows Vista and Windows Server 2008 but this issue is not limited to those two
- Window ghosting is not the only cause of this issue, so you might continue to see the error message even if window ghosting was turned off
Here are the workarounds we know so far...
Workaround 1: Disable Window Ghosting as described in this post.
Workaround 2: Debug the X++ code down to the line that is causing the error. Once identified, insert one line before this statement a call to the yield method of the xInfo class.
Example: infolog.yield();
namespace = outlook.getNamespace(#mapidef);
Workaround 3: Debug the X++ code down to the line that is causing the error. Once identified, place the statement inside a try / catch block. In the catch block simply retry the operation.
Example: int retryCount = 3;
//...
try
{
namespace = outlook.getNamespace(#mapidef);
}
catch(Exception::Error)
{
retryCount--;
if(retryCount > 0)
retry;
else
throw(Exception::Error);
}
Subscribe to:
Posts (Atom)