Start a workflow when a definition is added

You can configure a workflow definition to start the workflow when an attribute is added to an asset in your Collibra Platform.

Further refinement of your filtering is only possible thorough a script task, once the workflow has started. Here, you compare the universally unique identifier (UUID) of the attribute type that started the workflow with the UUID of the Definition attribute type. You can adapt the scenario to suit your needs.

To get the UUID of the attribute that started the workflow, use a method of the Java Workflows API event bean: event.getEventResourceId()

Note   Starting a workflow when new attributes are added to assets has the potential of impacting the performance of your environment, for example when you import large amounts of resources. Even if you refine the filtering to very particular cases, the workflow still needs to start for every new attribute that is added to an asset to be able to perform the script task.

Example workflow

You can download the DefinitionAdded example workflow and use it as a starting point for your own workflow.

The workflow checks if the attribute that is added to an asset is a definition and assigns a task to users with the Sysadmin role. If the attribute is not a definition, the workflow ends.

The start event form has two string process variables that can be changed from the Collibra Platform workflow definition page:

  • The out-of-the-box UUID of the Definition attribute type:
    • Id: definitionId
    • Default: 00000000-0000-0000-0000-000000000202
  • A candidate user expression for the users with a Sysadmin role. The variable is only needed for this particular example:
    • Id: adminUserExpression
    • Default: role(Sysadmin)

The Groovy script task performs the following operations:

  • Assigns the UUID of the attribute that started the workflow to an attributeId variable.
  • Creates a new Attribute object that corresponds to the attribute that started the workflow.
  • Gets the UUID of the attribute type and assigns the value to the attributeTypeId variable.
  • Gets the name of the asset that has the attribute and assigns the value to the assetName process variable.
  • Gets the contents of the definition and assigns the value to the definitionText process variable.
  • Compares the UUID of the attribute type with the UUID set by the definitionId process variable:
    • If there is a match, the value true is assigned to the isDefinition process variable.
    • If not, the value false is assigned to the isDefinition process variable.
import com.collibra.dgc.core.api.model.instance.attribute.Attribute

def attributeId = event.getEventResourceId()
Attribute attribute = attributeApi.getAttribute(attributeId)
def attributeTypeId = attribute.getType().getId()

def assetName = attribute.getAsset().getName()
def definitionText = attribute.getValueAsString()
execution.setVariable("definitionText", definitionText)
execution.setVariable("assetName", assetName)

if (attributeTypeId == string2Uuid(definitionId)) {
	execution.setVariable("isDefinition", true)
}
else {
	execution.setVariable("isDefinition", false)
}

The exclusive gateway stops the workflow when the isDefinition process variable is false. When isDefinition is true, the workflow continues:

  • In this example workflow, the users with the Sysadmin role receive a task, which notifies them that a definition has been added to an asset, including the name of the asset and the contents of the definition.