Navigation:   • Front page   • Public gallery  

lehr.dk - Dynamics AX

Some Dynamics AX (Axapta) tips

To start the Table Browser on system tables, e.g., UserInfo or UserGroupList, go to:

	AOT > System Documentation > Tables > [Table name] - right-click Add-Ins > Table browser

To obtain the name of the computer on which this code executes:

To pass a container to an object in Args you need to encapsulate the container in an object, e.g.:

    Container c = [1,2,3]; 
    ContainerClass cc = new ContainerClass(c); 
    _args = new Args(); 
And in the receiving class:
static void main(Args _args) 
    ContainerClass cc; 
    Container c; 
    cc = _args.parmObject(); 
    c = cc.value(); 

AxCreateNewProject: a project that makes it easyer to create new projects in Dynamics AX.

To determine whether code is running on server or client, use:
info(global::isRunningOnServer() ? "on server" : "on client");

To open a browser on a web page from Dynamics AX, use:

To get the server name of the current AOS server, use (returns an empty string in 2-tier (Dynamics AX 3.0)):
xSession xSession = new xSession();

How to use insert_recordset to insert from several tables:

        insert_recordset T1 (A, B) 
          select A from T2 
          where T2.... 
          join B from T3 
          where T3... 

Splitting filenames (very handy):

      [path, filenameOnly, type] = fileNameSplit(filename);

Getting a label in another than the current language:

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

Setting properties on fields on a datasource

    Example 1:
    Example 2:

Base64 decoding a string in Dynamics AX 3.0
I've developed this method to do it:

	 // 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 = decode.call( 
	            1,                           // Base64, without headers 
	        lasterr = DLL::lastDLLError(); 
	        TifSz += #TIFSzInc; 
	    if (!retval) 
	        throw error(strfmt("%1 (%2)",WINAPI::formatMessage(lasterr),lasterr)); 
	    return decoded; 

Some Dynamics AX (Axapta) related links

Valid HTML 4.0! Powered by HP Viewable with any browser Eclipse


Go to top of page

ZIP Stat
This page was changed: 2008/09/29 18:52.
User agent: CCBot/2.0 (https://commoncrawl.org/faq/)