In AX2009 you used to have two different status for assigned Purchase Requisitions in workflow, namely: “Pending Completion” and “Pending Approval”. Unfortunately in AX2012 this has become simply “In Review” to signify it being in workflow. This allows a more flexible approach to the ordering and reuse of elements in workflow. However it does not provide a clear way to distinguish where the Purchase Requisition is currently in the workflow process especially whether or not the item is currently assigned as a task or an approval.
The code below provides the X++ select statement to determine whether a document in workflow has at least one pending Task based workitem linked to it.
public display NoYes isTask() { WorkflowWorkItemTable workflowWorkItemTable; WorkflowElementTable workflowElementTable; select firstonly ElementId from workflowWorkItemTable where workflowWorkItemTable.RefTableId == this.TableId && workflowWorkItemTable.RefRecId == this.RecId && workflowWorkItemTable.Status == WorkflowWorkItemStatus::Pending join ElementId, ElementType from workflowElementTable where workflowElementTable.ElementId == workflowWorkItemTable.ElementId && workflowElementTable.ElementType == WorkflowElementType::Task; return (workflowWorkItemTable.RecId == 0) ? NoYes::No : NoYes::Yes; }
Note: If you’re using line level workflows or parallel branches you may not be guaranteed that the result is what you are logically looking for. It will simply return if there is at least one pending task workitem linked.
This post was inspired by forum question: https://community.dynamics.com/ax/f/33/t/161105
Workflow Wishlist #3
4 10 2010The item sitting at number 3 of my workflow wishlist is to have the canSubmitToWorkflow logic, that currently resides as a method on your workflow enabled forms, sit within workflow configurations or within a class linked to your workflow template. It seems strange to me that almost all the logic and complexity of the workflow sits in nicely packaged/distinct bundles i.e. templates and configurations, except for this one method. I would ideally like to be able to install a new template at a client site and without modifying the form, already have my canSubmit logic active.
Workflow does provide activation conditions per configuration, but my success using these has been fairly limited.
My workaround:
I have the habit of creating a static canSubmit method on all my WorkflowActionManager classes (i.e. per template) which I call from the canSubmitToWorkflow method on the form, this way it keeps the code fairly separate. The drawback is still that i cannot have different logic being performed if I have multiple configurations setup.
Please post any comments as to whether you have experienced similar issues or if you agree/disagree with me in this wish.
Happy daxing.
Rate this:
Share this:
Comments : Leave a Comment »
Tags: canSubmitToWorkflow
Categories : Comments and Suggestions, Customisation, Dynamics AX 2009, Idea's to remember, Wishlist, Workflow