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

  • Jonathan  Halland Profile Picture
    11,306 on at
    RE: Submit Purchase Order to Workflow through Code

    Hi Steve. My apologies, its just WorkflowTrackingStatusTable.

  • Community Member Profile Picture
    on at
    RE: Submit Purchase Order to Workflow through Code

    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.

  • Verified answer
    Jonathan  Halland Profile Picture
    11,306 on at
    RE: Submit Purchase Order to Workflow through Code

    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
    RE: Submit Purchase Order to Workflow through Code

    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,306 on at
    RE: Submit Purchase Order to Workflow through Code

    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.

  • Suggested answer
    dolee Profile Picture
    11,279 on at
    RE: Submit Purchase Order to Workflow through Code

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,043 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,864 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans