web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Submit Purchase Order to Workflow through Code

(0) ShareShare
ReportReport
Posted on by

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.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    dolee Profile Picture
    11,279 on at

    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.

  • Verified answer
    Jonathan  Halland Profile Picture
    11,310 on at

    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.

  • Community Member Profile Picture
    on at

    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?

  • Verified answer
    Jonathan  Halland Profile Picture
    11,310 on at

    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)

  • Community Member Profile Picture
    on at

    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.

  • Jonathan  Halland Profile Picture
    11,310 on at

    Hi Steve. My apologies, its just WorkflowTrackingStatusTable.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans