Nav 2016 Events and Workflow Walk Through – 6

This is the sixth of a multi part series on Nav 2016 events and workflows. This post will be on how to set up workflow step/ response combinations.

First part : What are events and the advantages they provide.

Second part: What are the builtin events and how to subscribe to events.

Third Part: Creating event subscribers

Fourth Part : What are workflows and how to make a workflow step

Fifth part: Making a workflow response

Sixth Part: Assigning workflow step and response combinations

Seventh Part: Assigning workflow step predecessors

Eighth Part: Putting it all together

Combo

Now that we have made a workflow step and a response to go with it. We need to set up the data so these two can be used together. By default, when ever a response gets added to the library, its is possible to be used with every workflow step. We want to limit this to only a few. This is because a lot of step/response combinations do not really make sense. For example, if we had a step for when an item is created, we font want the user to be able to add a response for setting the defaults on a customer. The code for this is very simple. The hard part is determining all the possible combinations you want. Then then finding where all the workflow event steps live in code.

clock-70189_1280

Another event

For setting up our step and response combinations we are going to subscribe to the “OnAddWorkflowResponsePredecessorsToLibrary” event in the Workflow Response Handling codeunit. This event passes you the code of the response that was just added to the library. Again, we are going to set up a switch statement based on the response code.  We will also need a workflow response handling codeunit variable. As well as any codeunit variable that have the events you want to match with. In the example below, my event is the WorkflowEvents codeunit. I also created a function in the event codeunit that exposes the code of the workflow step.

That is all you need. You just have to add a new “AddResponsePredecessor” line for each combination you want. If you don’t do this, then by default all combination are allowed. If for any reason you forget a combination you can simple go to the “Workflow Event/Response Combinations” page. The other options is to delete the response from the response table. Change the code. And then re-add the response by opening the workflows page.

The user can always change the combinations them selves. But at least setting it up for them gives them enough to work with.  Again, this setup isn’t required for workflows. But it does make changing workflows that much easier by only allowing the proper possible combinations.

Next we will look setting up workflow step order – 03/30/2016

Leave a Comment