Organisation-wide Workflow Email Templates

22 08 2012

If you make use of organisation wide workflow configurations in AX2012 you may have come across an issue where users are not notified of their new work-items via Email.

To set this up you will need to:

1. Navigate to your email templates under the Setup menu of “Organisation Administration”.
2. Select the “Show system email templates”
3. Create a new Email template.


4. Navigate to “System Administration” -> “Setup” -> “Workflow Parameters” and select your newly created email template. (For company specific configuration AX looks at the template selected under “Organisation Administration” -> Setup -> Workflow Parameters)

Your users should now be notified of “Organisation-wide” workflow workitems.

Adding code templates/shortcuts in AX 2012

19 03 2012

If you’ve got any blocks of code that you use frequently, e.g. specific comment blocks, you can very easily add code short cuts in AX 2012 to auto-insert the them in to your X++ code.

For example you can setup AX to automatically create surrounding comment such as

whenever you type “mycom” and press the tab key.

How do you accomplish this. Very easily!

Step1: Locate the class EditorScripts in the AOT.
Step2: Create a new method with the format public void template_flow_[shortcut](Editor editor)
Step3: User the editor parameter to add code the code that you would like inserted. e.g. editor.insertLines(“\\test comment”);
Step4: Add your method to the case statement in the isApplicableMethod method in the section relating to template “editor scripts that does not apply to Macros” 

Thats it, now if you type your shortcut into any editor in AX and press tab, the “\\test comment” code will be inserted.

Here’s a full example method

The above creates the following output:

How do I select from table Common in AX?

16 11 2011

Workflow quite often uses fields such as ContextTableId and ContextRecId to reference the original document. I’ve been needing to get hold of the original database record as a Common object from which I can then do various things, but the question is how do i get that common object?

I’ve tried something like this

Common buffer;
select buffer where buffer.TableId == _tableId && buffer.RecId == _recId;

This however always return an empty buffer regardless of whether or not the record does exist. I eventually managed to retrieve a common record with the following method.

Common buffer;
SysDictTable dictTable;
dictTable = new SysDictTable(_tableId); buffer = dictTable.makeRecord(); select buffer where buffer.RecId == _recId;

I’ve needed to do this a couple of times in the past and kept forgetting, so I’m posting it here for myself and who ever else wants to accomplish this. Enjoy!

DLLs used in Batch processes

13 10 2011

I know this doesn’t have a lot to do with workflow in specific, but I struggled through this issue for a while without finding any other results on the net, so I’m posting it just in case somebody else struggles with the same issue.

We are running a batch job that makes use of a 3rd party DLL file. The batch process runs quite ok if we run it manually from the client, however as soon as we try and run it in batch mode it fails with a “CLR Error: cannot create object”.

The reason for this is that the batch server cannot find the DLL file to use. All the recommendations that I found to solve this error involved placing the DLL in the Global Assembly Cache (GAC) on the batch server. I understand that this would be the best way to overcome the error and should normally be the approach. However the DLL we have is not Strongly Named, so we received constant errors when trying to add it to the GAC. Unfortunately the vendor is not shipping a strongly named version of the DLL so a different approach has to be followed.

Where for client side execution of the DLL you need to place the file in C:\Program Files (x86)\Microsoft Dynamics AX\50\Client\Bin if you would like the server to access it, simply place it in C:\Program Files\Microsoft Dynamics AX\50\Server\[AOS name]\Bin on the batch server.

And like magic the batch job works. (Ok i had to restart the batch server AOS as well)

I hope this assists somebody in the near future.

The Request Failed with HTTP status 401: Unauthorized

20 09 2011

I’ve been battling through “fixing” a clients Workflow setup. Its been working for the last while but just stopped all of a sudden. I tried to validate the workflow website and received the message “The Request Failed with HTTP status 401: Unauthorized”. I went through some of the suggestions made by Amer over at his blog to fix the error before reviewing the server name specified for the workflow website. It happened to be set to the server’s IP address, after changing this back to the valid server name all was well!

New: http://CLIENTAOS_SERVER:80/MicrosoftDynamicsAXWorkflow50

I hope this helps somebody.


Business Connector code refresh

15 04 2011

While developing business connector applications you may come across issues where you code changes in AX do not seem to be taking effect or the caching is taking too long to refresh. I’ve tried restarting the AOS, restarting IIS, restarting Application pools even restarting the entire server and nothing seemed to have helped. However, an easy way to ensure that your changes are always available to the business connector code is to add the following line at the beginning of your .NET code, after loggin in, but before executing your custom code:
DynAx.CallStaticClassMethod(“SysFlushAOD”, “doFlush”);

(where DynAx is a logged in instance of Microsoft.Dynamics.BusinessConnectorNet.Axapta)

I hope that helps someone.

Some pointers on developing your own ledger journal workflows

18 03 2011

I did a couple of developments on ledger journal workflows a while ago and wrote down these pointers for myself to remember when doing it again.

1) Remember that your workflow must be linked to the same module / workflow category that the journal you wish to workflow is linked to i.e Customer, Vendor or Ledger
2) The template that is used for each LedgerJournalType must be defined in the LedgerJournalWFApprovalTemplates macro. (examined from: LedgerJournalName::findJournalTemplate)

%d bloggers like this: