Question Status

Verified
Steve Murphy asked a question on 24 Mar 2015 8:07 PM

I have a requirement to handle the following scenario through code:

  1. Create a change request for a purchase order
  2. If workflow is on for the given purchase order, submit the request to workflow
  3. Change location for one or more line items
  4. Re-confirm the purchase order

It appears that I can create the change request using the VersioningPurchaseOrder class, so I don't anticipate problems there.

However, I can't determine what the submit button on the workflow action bar is connected to. How do you find the code behind that? I don't see anything in the form on the AOT that points to the workflow action bar.

Next, how do you about determining when the submitted change request has actually been processed.

Lastly, where can I find more information about working with workflow processing through code?

Thanks in advance for any help provided.

Reply
Suggested Answer
Dominic Lee responded on 24 Mar 2015 11:03 PM

Hi Steve,

The link below talk about how to create a SubmitToWorkflow class for a particular workflow.

https://msdn.microsoft.com/en-us/library/cc583139.aspx

The line:

Workflow::activateFromWorkflowType(_workflowTypeName, _recId, _initialNote, NoYes::No);

is of most interest to you. You can use this method from the Workflow class directly in your code to start a workflow.

kind regards,

Dominic Lee

My blog | PBC

This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

Reply
Verified Answer
Jonathan Halland responded on 25 Mar 2015 2:07 AM

Hi Steve.

Dominic's suggestion provides you with the basic code to auto-submit a record into workflow. However calling this on its own may by-pass certain business logic being executed when manually submitting a record into workflow e.g. Changing the record's status to in review etc....

For your workflow take a look at the code in the class behind the submit menuitem. For Purchase Orders this is the PurchTableWorkflow class, with particular focus on the Submit method which calls through to the "submitToWorkflow" method on the purchTable. In this method, the versioning takes place.

General AX Enthusiast and Blogger

http://www.exploreax.com

Reply
Steve Murphy responded on 25 Mar 2015 12:53 PM

Two additional questions:

  1. After submitting the change request to workflow, how do I determine when it has finished processing?
  2. I will have some older open orders under workflow, and new orders that are not under workflow. How do I determine which are under workflow, and which are not?

Reply
Verified Answer
Jonathan Halland responded on 26 Mar 2015 1:37 AM

Hi Steve, the simple answer is to look at your Purch status to see whether it is in Review or approved/confirmed. You can also lookup in your workflow tables to see if there are any active workflows for your record. (SysWorkflowTrackingStatusTable)

General AX Enthusiast and Blogger

http://www.exploreax.com

Reply
Steve Murphy responded on 26 Mar 2015 11:16 AM

Thanks. It appears that I can also check the value of ChangeRequestRequired on the PurchTable record.

I don't see a SysWorkflowTrackingStatusTable in the AOT. We are still on RTM.

Reply
Jonathan Halland responded on 27 Mar 2015 1:23 AM

Hi Steve. My apologies, its just WorkflowTrackingStatusTable.

General AX Enthusiast and Blogger

http://www.exploreax.com

Reply
Verified Answer
Jonathan Halland responded on 25 Mar 2015 2:07 AM

Hi Steve.

Dominic's suggestion provides you with the basic code to auto-submit a record into workflow. However calling this on its own may by-pass certain business logic being executed when manually submitting a record into workflow e.g. Changing the record's status to in review etc....

For your workflow take a look at the code in the class behind the submit menuitem. For Purchase Orders this is the PurchTableWorkflow class, with particular focus on the Submit method which calls through to the "submitToWorkflow" method on the purchTable. In this method, the versioning takes place.

General AX Enthusiast and Blogger

http://www.exploreax.com

Reply
Verified Answer
Jonathan Halland responded on 26 Mar 2015 1:37 AM

Hi Steve, the simple answer is to look at your Purch status to see whether it is in Review or approved/confirmed. You can also lookup in your workflow tables to see if there are any active workflows for your record. (SysWorkflowTrackingStatusTable)

General AX Enthusiast and Blogger

http://www.exploreax.com

Reply
Suggested Answer
Dominic Lee responded on 24 Mar 2015 11:03 PM

Hi Steve,

The link below talk about how to create a SubmitToWorkflow class for a particular workflow.

https://msdn.microsoft.com/en-us/library/cc583139.aspx

The line:

Workflow::activateFromWorkflowType(_workflowTypeName, _recId, _initialNote, NoYes::No);

is of most interest to you. You can use this method from the Workflow class directly in your code to start a workflow.

kind regards,

Dominic Lee

My blog | PBC

This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

Reply