Define a script task

To save the user comment, use a script task that calls the addComment() method of the CommentApi Java class. The method has an AddCommentRequest parameter. The AddCommentRequest class has a builder() method available.

  • Class: CommentApi
    • Main method: AddComment()
      • Parameter and builder method: AddCommentRequest.builder()
Builder parameters Mandatory Type Description
baseResourceId() Yes UUID Sets the ID of the resource which the new comment is for.
baseResourceType() Yes ResourceType Sets the type of the resource which the new comment is for. For instance Asset, Community, Relation.
content() Yes string Sets the HTML content of the comment.
build() Yes   Builds the object.
baseResource() No ResourceReference Sets the resource which the new comment is for.
parentId() No UUID Sets the id of the parent comment.
import com.collibra.dgc.core.api.dto.instance.comment.AddCommentRequest.Builder

commentApi.addComment(AddCommentRequest.builder()
	.baseResourceId(item.getId())
	.baseResourceType(item.getType())
	.content(Comment.toString())
	.build()
);

Because each script task is independent, include import statements for all the packages you are using in a script for each script task. Avoid using generic imports to reduce execution time.

In the context of workflow script tasks, the <Resource>Api interfaces (such as AssetApi, CommunityTypeApi, FileApi, and so on) are already instantiated and accessible via <resource>Api variables (such as assetApi, communityTypeApi, fileApi, and so on).

  1. From the Tasks section of the Palette, drag a Script task to the Chief steward lane, after the user task.
  2. Connect the user task to the script task with a SequenceFlow connection.
    Make sure that the start and end event stay connected through the user and script tasks.

    You can also create elements starting from an other element by hovering your pointer over it and clicking the create element button:

  3. In the Properties section, select the General tab.
  4. In the Name field, enter a name for the task, for example: Store comment.
  5. Select the Main config tab.
  6. From the Script language drop-down menu, select groovy.
  7. Paste the code from the example in the Script form.

The following image shows the current state of the workflow:

At this point, you can try to deploy your workflow in Collibra. Save your work and see Deploy a workflow.

About the item variable

The global variable item used in the code refers to the resource the workflow applies to. For more information, see the Workflows beans API documentation of your Collibra Data Intelligence Platform available at https://<your_dgc_environment_url>/docs/index.html, or the Beans section of the product documentation.

Whenever you have to add a comment to an asset, you can copy the code in the example.