Categories
#Effect fragment

Effect fragment

DCR Portal 7.5.1 introduces effect fragments. Effect fragments makes it easier to share common functionality between several graphs. The common functionality is used like any existing effect. An effect fragment is defined as a DCR graph and configured in the custom effect configuration found under effect administration.

A simple example

Please look at the decision model and notation example. We have converted this into an effect fragment.

Instead of using a DMN table directly in the graph, we've hidden the DMN table in another graph.

The graph is quite simple. The user fills out country and age in a form, and then the effect fragment computes what is allowed:

The effect "DMNAlcohol" takes two paremeters:

Find the graph here: https://www.dcrgraphs.net/Tool?id=2001169

The effect fragment is defined by another graph: https://www.dcrgraphs.net/Tool?id=2001168

The graph must always have a start event with the id __START__ marked as an interface event from outer, the "i" in the lower right corner of the start event.

When you try out the process in DCR Simulator the effect fragment will be injected into the graph you simulate as outlined below:

You notice that the "start" event of the effect fragment is replaced with the Compute event of the original graph where the parameters were specified.

When you fill out the form the computation is made. A new subgraph is spawed that executes the computation.

We notice that Denmark and the age of 17 allows the person to purchase Beer and Wine.

An advanced example - WZ.CopyDocument

Since the introduction of dynamic effects, it has been our intention to create an effect package corresponding to the existing static WorkZone effects. However, effects like CopyDocument could not be wrapped into a single effect as it potentially copies many onto a specific case.

We decided to use DCR graphs to create such shared logic rather than inventing a new programming language.

The logic that retrieves and copies documents from one location to another in WorkZone is a bit complicated., but using the logic is simple, just like using the static WorkZone CopyDocument effect.

All dynamic effects that updates anything always have three activities, ContinueOnOK, ContinueOnFail, ContinueOnTimeout. The reason for this is error handling. With dynamic effects you can handle any error occurring in an effect in the graph.

Effect Fragment Graph: https://www.dcrgraphs.net/Tool?id=2001424

Methodology setting up an effect fragment

In order to define a new effect fragment you should initially identify the input and the output from the effect fragment. In DCR input to effects is provided in the effect parameter window outlined above. In an effect fragment input is defined as the parameters to the graph.

The parameters to the WZ.CopyDocument effect fragment is skected below:

The output is provided through the ContinueOnOk, ContinueOnFail and ContinueOnTimeout events. These events are defined as interface from outer events as illustrated below. Notice the blue box to the right:

In order to execute the activities that brings out value from the effect fragment you must use the effect DCR.EffectContinue. This effect takes an optional value and an activity as parameter and ensures this activity is executed and if any value is provided, the value is assigned to the activity.

The logic of the DCR graph follows the normal DCR semantics.

In the case of WZ.CopyDocument we first retrieves a list of documents to copy using the WorkZone dynamic effect WZ.GetList. It reads from the Records object in WorkZone using DocumentQuery as input:

The we loop through the list and for every document we first retrieve its URL using the effect WZ.GetDocumentLink. Then we get the document using the effect WZ.GetDocument. We then upload the document to WorkZone and add it to the case using the filename etc.

Note: We have not yet tested the effect fragment WZ.CopyDocument in WorkZone or DCR Simulator. This is currently work in progress. Once it is fully tested and verified we will ensure the fragment listed here is correct.

Related Release notes

Release 7.5.2

  • Welcome to Graph Governance
  • Welcome to Effect Fragments

Related Videos

DCR Portal 7.5 release webinar

Related Examples

Related Articles

No related articles found.