Morten Lehrmann's Dynamics AX Blog

Error: Unable to log on to Microsoft Dynamics AXIssues

Posted by Morten Lehrmann 2014-02-17 15:38:21

Got this error when starting my client for one of our Dynamics AX 2009 installations. Connections to other installations from the same client computer worked perfectly.
Connecting from another client computer with the same credentials worked perfectly.

The client computer is running Windows 7.
Control Panel\All Control Panel Items\Credential Manager
and deleted credentials for the AOS from Windows Credentials.

That solved the issue.

Dynamics AX 2009 AIFTips

Posted by Morten Lehrmann 2014-01-09 09:49:53

Adding DocuRefs to Query AxdPurchaseRequisition

When adding the DocuRef table to Query AxdPurchaseRequisition for use by AIF you may experience that the Documents you export from AIF does not include the new DocuRef entries.

The reason for this may be found in class AxdPurchaseRequisition method initQuery:


The tricky thing is the constants 1 and 2. They are described here:
Although it is not described how to numbering works.
However, the issue is that depending on where in the AxdPurchaseRequisition query you add DocuRef you may need to renumber these.

In my case changing 2 to 3 did the trick:


Managed to create this strange table fieldIssues

Posted by Morten Lehrmann 2010-11-02 12:01:57

Blog image

How to make a simple Enterprise Portal Web Part Page to update data in Microsoft Dynamics AX 2009Tips

Posted by Morten Lehrmann 2009-06-15 13:14:33

An environment with Microsoft Dynamics AX 2009, Visual Studio 2008, Enterprise Portal developer tools, and an Enterprise Portal on Sharepoint.

The demo walks you through the steps needed to develop a simple Enterprise Portal Web Part Page to view and update columns of the VendTable in a grid.
Many details are omitted and knowledge of the used systems is required.

Steps -
AX2009: Step to do in Microsoft Dynamics AX 2009.
VS2008: Step to do in Visual Studio 2008.
EP: Step to do in Enterprise Portal.

AX2009: Create a data Set named DemoVendTable. Set Data Source to VendTable. Set property <InsertIfEmpty> to <No>.

VS2008: Create a new .NET Framework 2.0 Web Site using the <Dynamics AX Web Project> template. Call it DemoAxWebProject.
VS2008: <Add New Item> of type Dynamics AX User Control to the Project. Call it VendTableAxWebUserControl.
VS2008: <Add to AOT> (It may be necessary to restart VS2008). Now the User Control is visible in AX2009: AOT>Web>Web files>Web Controls (restart may be neccessary).
VS2008: <View Designer> on VendTableAxWebUserControl
VS2008: In the Toolbox in the Dynamics AX section: Add an AxDataSource - set DataSetName to DemoVendTable
VS2008: In the Toolbox in the Dynamics AX section: Add an AxGridView - set Data Source to the data source created above. Set DataMember to <VendTable_Current>.
VS2008: In the Toolbox in the Dynamics AX section: Add an AxGroup - set FormID to the AxGridView created above.
VS2008: In Fields property of AxGroup add Fields: AccountNum, Name, VendGroup.
VS2008: Set <AllowEdit> and <AllowDelete> to <True>.
VS2008: Build the solution (F6).

EP: <Site Actions>: <Create> <Web Part Page> Name: DemoVendTable. Layout: <Full Page, Vertical>. Document Library: <Enterprise Portal>.
EP: <Add a Web part> - <Dynamics Infolog Web Part>.
EP: <Add a Web part> - <Dynamics User Control Web Part>.
EP: <Edit> <Modify Shared Web Part>. Set <Managed content item> to <VendTableAxWebUserControl>. <Apply> <OK>.
(May require iisreset /noforce).

Showing the old main menu in AX2009Tips

Posted by Morten Lehrmann 2009-05-18 08:39:22

It is still possible to display the old main menu in AX2009.

Use this job:

static void ShowMainMenu(Args _args)
{ Menu Menu;
Menu = new Menu(#MainMenu);

How to do customizationsTips

Posted by Morten Lehrmann 2009-04-07 16:52:04

Very good presentation about doing customizations in Dynamics AX:


Base64 decoding a string in Dynamics AX 3.0 Tips

Posted by Morten Lehrmann 2009-04-07 16:43:25

// Transforms the base64 encoded string _encoded to it's binary representation.
// Throws an error on errors.
static Binary base64decode(str _encoded)
// The size in bytes of the binary representation is found by trying
// to convert until it fits
#define.minTIFSz(30000) // Minimum try
#define.maxTIFSz(900000) // Maximum try
#define.TIFSzInc(10000) // Increments during trying
DLL DLL = new DLL('crypt32.dll');
DLLFunction decode = new DLLFunction(DLL, 'CryptStringToBinaryA');
int retval; // BOOL
int encodedlen;
int lasterr;
Binary decoded;
Binary junk1 = new Binary(#SizeOfInt);
Binary junk2 = new Binary(#SizeOfInt);
Binary size = new Binary(#SizeOfInt);
int TIFsz;


BOOL WINAPI CryptStringToBinary(
__in LPCTSTR pszString,
__in DWORD cchString,
__in DWORD dwFlags,
__in BYTE *pbBinary,
__inout DWORD *pcbBinary,
__out DWORD *pdwSkip,
__out DWORD *pdwFlags
decode.returns(ExtTypes::DWord); // BOOL
Exttypes::String, // __in LPCTSTR pszString,
Exttypes::DWord, // __in DWORD cchString,
Exttypes::DWord, // __in DWORD dwFlags,
Exttypes::Pointer, // __in BYTE *pbBinary,
Exttypes::Pointer, // __inout DWORD *pcbBinary,
Exttypes::Pointer, // __out DWORD *pdwSkip,
Exttypes::Pointer // __out DWORD *pdwFlags

encodedlen = strlen(_encoded);
TIFSz = #minTIFSz;
lasterr = #moredata;
while (lasterr == #moredata) // As long as the image is too large
if (TIFSz > #maxTIFSz)
throw error(strfmt("The eInvoice image is larger than %1 bytes - cannot handle this",#maxTIFSz)); //TODO:Label
decoded = new Binary(TIFSz);
retval =
1, // Base64, without headers
lasterr = DLL::lastDLLError();
TifSz += #TIFSzInc;
if (!retval)
throw error(strfmt("%1 (%2)",WINAPI::formatMessage(lasterr),lasterr));
return decoded;

Getting a label in another than the current languageTips

Posted by Morten Lehrmann 2009-04-07 16:42:09

SysLabel::labelId2String(literalstr("@SYS1"), 'en-gb')