Here a short story of the session that I attended about “Workflow for Developers” by Stuart Glasson.
During the ACE program, I haven’t been working with Workflow that much. I have been involved with Eventing and Extensions quite a lot, but no Workflow. Now, I know that the new Workflow functionality in Microsoft Dynamics NAV 2016 is using eventing .. and I never understood why Microsoft is publishing events, and subscribing to it themselves. Let’s see if Stuart makes it clear to me.
First a disclaimer: typing this blog in the room, doesn’t allow me to catch all details – so I might be off at some points .. This blog is “as is”. Again, full of typo’s – sorry for that – ignore them 😉
First an overview – what is in scope, and what not. Well, I missed a big part by writing the above 🙂 .. But it comes down to: workflows need to be configurable, notifications should be in it, … NAV is giving you a certain workflowout-of-the-box (approvals), but this shouldn’t be the end of it. In a way, the built it upon a framework, and that’s what you should use to extend your workflows for your verticals.
Everyone that is going to participate in a workflow, is a user .. And should be configured as a user.
Next, the approval-part should be set up with that user. Basically, he set up some kind of hierarchy (who reports to who).
Next, Stuart sets up the “Workflow User Groups”. Makes sense: a group of users can have the same “job”, or in this case, can approve certain approval requests.
Eventually, Sutart creates a new Workflow in the “workflows” page. Microsoft really created already quite a lot events that workflow can use. These events are based on the Eventing-functionality that has been built into the platform. You will hear a lot of that in the very near future ;-).
In this case, he’s creating this event: When a purchase doc is released, show a message as a workflow response. And showed it worked when he released a new purchase invoice.
On top of this, out-of-the-box, we will get quite some workflow templates already, which they worked out for us. Some examples:
- Approvals of incoming documents
- OCR workflow
- General journal batch approval
- Sales invoice approval workflow
- Customer approval workflow
It should also be used as a template for developers (last example is kind of a good example for that). If you want to extend with whatever you want as workflows, based on entities in your vertical – look at how they did it!
On top of that: you can export workflows to be able to transfer from one customer/test/.. Environment to another.
A note on Events.
Stuart mentioned a difference between platform events and Workflow Events (I’m getting to get the picture why they did it this way …). Workflow need a couple more things to do to be able for users to use the events that you might have published. You should add events to a library, and handle the event in the workflow.. (basically).
There are a few building blocks for workflow:
- Events (Eventing)
- Responses (mail, notification, message, …)
- Dynamics filter page/response group
- Control of flow
- Workflow combinations
If you read this – really – don’t you have the impression it’s not “basic” at all? It’s quite extended, if you ask me ;-).
Stuart next demoed an example where he creates a new event, and built a workflow on top of that (event was: when a campaign finishes ..).
- Creating a new codeunit, and creating a new subscriber function – “run me when anything changes on the table “campaign”)
- Add the event to the library, by adding a function (eventsubscriber), by calling a workflowfunction (AddEventToLibrary). –> this way, workflow is calling the event, and by adding that code, your event is added in the workflow system automagically (need trick :-))
For the response:
- Add another codeunit, with a subscriber function doe add a response to the library (very similar as above)
- And add a subscriber to (in this case) RunReportResponse. If the conditions are met, run the report – a quite straight forward eight-line-function.
Next, you need to be able to get parameters for running certain business logic in a certain context. These are the “options”-part I talked about above. This is kind of complicated to explain: basically, there is a page 1523, and all different kinds of options, are aggregated on this page, and you just refer as “group” to which set of options you’d like to show. You might have to extend that page – though, “group 0” is “I don’t have any options” (which most of the time might be the case).
On top of that, if you don’t do any work, Microsoft is still generating an options page, based on the record that you’re working on. I saw it, don’t really have a clue yet in which context it is exactly (sorry for that) .. . Basically, he was creating a new workflow on our new event, and as a response he runs a report, with some report-parameters he set up dynamically.
Really cool – in 15 minutes, we basically built a new (basic) workflow.
One extra thing worth mentioning, is the “workflow Event/Response Combinations”. By default, everything will run – and if you don’t want that – if there are combinations between some of them – then there is this page to avoid that. Makes sense once more ;-).
Next, something that really excites me: workflow as a customization Extension. You can! You can package up a workflow and deploy it at tenants or whatever. Cool!
Great session and great software, Stuart. I totally got why you are using Events now .. Thanks!