Workflow Types in AX 2012

22 01 2015

Looking for a list of Workflow Types (Templates) available in AX 2012:

Mass Resume Line Workflows

14 11 2014

Orginally from my new blog:

<strong>Challenge/Problem</strong>: Many line level workflows that need to be resumed.

<strong>Description</strong>: Sometimes due to data or setups one may have numerous line level workflows failing and entering a “Stopped” state. This may be a result of calendars that do not have enough dates created, users who have been disabled etc… If the workflows were header level, it is easy enough to select all in the Workflow History form and click resume, however on line level workflows one needs to view each line level workflow individually and resume them.

<strong>Solution</strong>: The following job can be used to perform mass resume on stopped workflows. You can adapt the SQL to limit to certain documents or document types of necessary.
<pre>static void resumeStoppedWorkflows(Args _args)
WorkflowTrackinStatusTable tracking;
int i, j;
while select tracking where tracking.TrackingStatus == WorkflowTrackingStatus::Faulted
&amp;&amp; tracking.WorkflowType == WorkflowTrackingStatusWorkflowType::DependentSubworkflow
try {
Workflow::resumeWorkflow(tracking.CorrelationId, “Auto-resumed”);
catch (Exception::Error)
//Some may not be able to be resumed but we dont want to stop the process
info(strfmt(“%1 workflows resumed, %2 workflows could not be resumed”));

Deleting a workflow Instance in Microsoft Dynamics AX 2012

22 05 2014

Deleting a workflow Instance in Microsoft Dynamics AX 2012

I’ve been wanting to write a tutorial explaining the tables involved in a workflow and how to delete an instance if necessary (e.g. when a major fault or data inconsistency occurs), however it seems Colin’s Dynamics AX 2012 blog beat me to it and he did a superb job at that, check it out here

AX2012 – On Reassign: Failed to create a session

23 01 2014

When trying to reassign a record via workflow history in AX2012 we received the error: Failed to create session; confirm that the user has the proper privileges to log in to Microsoft Dynamics.

Screen Shot 2014-01-23 at 2.31.28 PM

The cause of our problem was a faulty CIL. We performed a full CIL compile, restarted AX and then were then able to perform the re-assign

Subworkflow Tutorial

13 01 2014

Since the launch of Dynamics AX 2012 I’ve been amazed at the amount of really good blogs that have started springing up. One such blog is Collin’s Dynamics AX2012 blog. After finding a whole load of question on Subworkflows in Dynamics AX, I considered writing up an article, but found a his tutorial very way more helpful than I could ever be, so please pay his site a visit!

Collin’s Dynamics AX2012 Blog – Subworkflows

JSON in Dynamics AX – Advanced example #1 (Basic Auth)

11 11 2013

After my previous post on using JSON in Dynamics AX2012 I have received a number of requests for some slightly more advanced examples. I will attempt over the next couple of weeks to provide some.

Today I will cover the use of Basic http authentication. There are a couple of non-intuitive tricks that one needs to use to get it to work.
Before performing any direct requests as per our previous example you will need to make some modifications to the headers in your RetailRequestWeb object.

The first header modification is to add the “Authorization: Basic ” header. You can do so by building up the header string as follows

System.Text.Encoding ascii;
str credentials;
credentials = "myusername:mypassword";
//N.B. Encode the credentials before adding them to your headers otherwise you will receive 403 unauthorized errors
ascii = System.Text.Encoding::get_ASCII();
credentials = System.Convert::ToBase64String(ascii.GetBytes(credentials));
//Combine header instruction and encoded credentials
request.parmHeader("Authorization: Basic "+credentials);

The second modification you need to make is set the request content type to “application/json” without this you may receive 403 unauthorized errors. The retails API allows you to set the content type easily by using the parmContentType method on your RetailRequestWeb object.


Finally the full example of constructing your json request ready for use:

RetailWebRequest request;
System.Text.Encoding ascii;
str credentials;

request = RetailWebRequest::newUrl(_url);
credentials = "myusername:mypassword";
ascii = System.Text.Encoding::get_ASCII();
credentials = System.Convert::ToBase64String(ascii.GetBytes(credentials));
request.parmHeader("Authorization: Basic "+credentials);

Using JSON in Dynamics AX

22 10 2013

I’ve recently had a requirement to integrate an external system (Toggl with Dynamics AX 2012’s Timesheet system. However the external system only provided a JSON API which isn’t supported natively by the Dynamics AX AIF system.  After some research and trial and error (using various DLL’s) I eventually stumbled across some really useful classes provided by the Retail module in Dynamics AX2012. These classes (although named “Retail…”) provide a really easy and elegant JSON interaction for any use. Here is a very basic code sample of how to consume JSON using these classes in Dynamics AX 2012.


static void myJob(Args _args)
    RetailWebRequest request; 
    RetailWebResponse response; 
    str rawResponse, value; 
    Map data; 
    RetailCommonWebAPI webApi = RetailCommonWebAPI::construct(); 
    request = RetailWebRequest::newUrl(""); 
    response = webApi.getResponse(request); 
    rawResponse = response.parmData(); 
    data = RetailCommonWebAPI::getMapFromJsonString(rawResponse); 
    value = data.lookup("elementname"); 
    info(strFmt("Element name: %1",value)); 

If you are interested in some more advanced examples of using JSON in AX (e.g. using authentication, retrieving subsets of info or arrays)  or doing some of your own integration into Toggl timekeeping please let me know and I’ll post some more info.


%d bloggers like this: