This is the Seventh of a multi part series on Nav 2016 events and workflows. This post will be on how to set up workflow step predecessors.
First part : What are events and the advantages they provide.
Third Part: Creating event subscribers
Fourth Part : What are workflows and how to make a workflow step
Fifth part: Making a workflow response
Seventh Part: Assigning workflow step predecessors
Eighth Part: Putting it all together
One before the other
When creating workflow steps, you might want to allow only certain ones to go before or after others. This post will be very similar to the previous post on the workflow step and response combinations. Mainly because we are again editing a large matrix of possibilities. Again, the hard part isn’t in the code, its determining all the combinations you want and trying to find them.
Didn’t we just do this?
The following steps will look very similar to what we just did for the step/response combinations.
First we are going to need a function that subscribes to the “OnAddWorkflowEventPredecessorsToLibrary” event in the Workflow Event Handling codeunit. This event passes you the code of the workflow step that was just added to the library. Again, we are going to set up a switch statement based on the step code. We will also need a workflow event handling codeunit variable. As well as any codeunit variable that have the events you want to set as a predecessor.
CASE EventFunctionName OF
That is all you need. You just have to add a new “AddEventPredecessor” line for each predecessor you want to set up. In the example above the ‘CUSTOMERCREATED’ workflow step is being set as a predecessor to the “OnsendCustomerFromApprovalCode”. What this allows you to set up your workflows properly. By only allowing the “OnsendCustomerFromApprovalCode” step to come after ‘CUSTEOMERCREATED’.
If you don’t do this, then by default all combination are allowed. you can step up steps in any order. If for any reason you forget a predecessor you can simplely go to the “Workflow Event Hierarchies” page. The other options is to delete the step from the workflow steps table. Change the code. And then re-add the workflow step by opening the workflows page.
The user can always change the predecessors 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 at combining all the previous things we learned to make a full workflow. – 04/04/2016