How to auto-submit record into workflow

23 06 2010

Just this past week I had a request from one of my blog readers asking how to automatically submit a record into Dynamics AX Workflow without making use of the standard submit button. E.g. on a specific event such as on completion of an RFQ to submit a PR to workflow.

We’ve had this type of request from clients before and its actually relatively simple to accomplish. Check out the PurchReqWorkflow class, method: submit.

You basically only need to execute the following line to kick off any workflow.


Adapted for your auto-submission and placed in the relevant section of code, one would use something like the following:

Workflow::activateFromWorkflowTemplate(‘PurchReqApproval’, //Template name
purchReqTable.RecId, //Record id of the document that you are submitting,
‘Auto-Submitted into workflow’, //A comment for the workflow history to know something about how this was submitted,
false, //This document wasn't submitted from the web,
Curuserid()); // The user who should become the workflow originator 

I you find this useful.

Happy Daxing





14 responses

18 07 2010

Thank you Jonathan.

Great post from a great blog by a great guy :).


26 09 2011
Bang Im

Hi Jonathan,

Thanks for the post here, very useful.. Just a quick question, if I have setup the workflow submission condition(i.e. the Set condition for use box in the workflow configuration), will this method honor that condition before submitting the workflow?


Bang Im

27 09 2011

I haven’t tested that yet. But I would guess that it won’t as you are forcing a specific template. However i’m not sure what would happen if you have multiple configurations for the same template all with activation conditions.

Sent from my iPad

1 10 2011
Bang Im

Thanks for the reply, Jonathan. It didn’t seem to validate that condition, so I ended up coding the condition in the X++ logic itself before submitting the workflow.

2 05 2012
Edvandro Santos

Hi Jonathan, great post!

But how can I approve/reject an workflow item already submitted using x++?

3 05 2012

WorkflowWorkItemActionManager::dispatchWorkItemAction( workItem, _comments, to_user, workItemActionType, _menu_item, false);

20 01 2014

Hi Jonathan,
I need to submit multiple records for workflow and approve or reject multiple workitem at the same time. is that possible to do.

28 05 2014

We have similar requirement, could you please suggest is it possible? Thank you.

19 03 2014

Hi Jonathan, do you know what is the process for approve in Ax 2012? don’t exist the method activateFromWorkflowTemplate, only exist activateFromWorkflowType.
Thank you!

20 03 2014

They have renamed Templates to Types in AX2012

On Wed, Mar 19, 2014 at 11:41 PM, Dynamics AX Workflow Wanderings wrote:


19 12 2014

Hi Jonathan,

I try to write the code in job and run it, but there is no respond in the PR. The submit button still there. Do you know why?


14 01 2015

Hi Celine. You may need to just review the code behind your PR Submit Menu item. There may be code that changes the PR status to “Submitted” you will then need to do this status change in your job as well.


3 06 2016

there is no method named “activateFromWorkflowTemplate” instead “activateFromWorkflowType” is there what to do for auto submit of generated record?

5 12 2016


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: