Workflows adding content for use in conditions
Workflows adding content for use in conditions
Workflows in Dynamics and FO I lacked experience with. A customer wanted more data to choose from in conditions when making decisions.
Customer requirements
Purchase requisition workflow, need the workflow to auto approve if the purchase orders attached projects manager is the approver.
This meaning, that a project manager should not need to approve his own purchase order, it should auto approve. The workflow does not have other project data than project ID, with our customer the project ID will always be used in purchase orders. So we can fetch wanted field from the project table named WorkerResponsible.
So this is straight forward and not complicated at all (ironic). Spent a few hours investigating and found two ways in achieving the customers requirements.
My investigations resulted in two possible solutions
- Extend the Query used, outer join project table to it.
- Create a computed field in the document class of the workflow
Identify class for business logic and query used
Extending the query and adding an outer join is trivial for a developer, but finding the specific used is more of a challenge.
To find what to extend you need to go here:
Procurement and Sourcing --> Setup --> Procurement and sourcing workflows.
The list of workflows have a column Type, this is the key to finding the code and query used.
The property Document is where the code resides including query and calculated fields.
To find the query search for the method named getQueryName. Extend this query to add your wanted content.
In the class PurchReqDocument you can add computed fields available for you in the workflow designer. To add a computed field you have to follow a specific method signature. Create en extension of the class and add your method there.
The method must have this specific signature:
public [EDT] parm[Name](CompanyId _companyId, TableId _tableId, RecId _recId)
Example
Click the ID column of your workflow and the workflow designer will open after you've logged in. In the properties of your conditional decision.
You now have more data to use in your conditions. We've added the computed field Purchase requisitions.Project Manager and the Projects table.
Comments
Post a Comment