T

Wednesday, September 14th, 2022 2:32 PM

Tracking Asset Attributes Changed

We have an interest in tracking changes to attribute fields made to assets and then notifying stakeholders through email tasks. To this end, we intend to develop a workflow triggered by the Start Event “Asset Attribute Changed.”

Given that there is no form for a start user to utilize, and we will lock down the workflow only for use by those with sysadmin permissions, I am assuming when developing this workflow that I can leave form properties in the start event blank when working in Eclipse IDE. This may or may not be an incorrect assumption.

With that assumption intact, I’d like to get to a second, script task wherein it seems we should be utilizing the interface NamedDescribedWorkflowStartEventType to set variables for distribution through a later mail task. The modifier WorkflowStartEventType that retrieves the event type may or may not be of much interest, given that we have yet to see what the getDescription() method actually spits out: a “human-readable” description that may be sufficiently encompassing our needs.

The following is my attempt thus far at the body of the script task “Main config:”

import com.collibra.dgc.core.api.model.workflow.NamedDescribedWorkflowStartEventType

String startEventName = WorkflowStartEventType getEventType(getName());

String startEventDescription = WorkflowStartEventType getEventType(getDescription());

execution.setVariable("name", startEventName);

execution.setVariable("description", startEventDescription);

Now, I may be wildly off base. If any of you would have suggestions as to how to improve this script task, please, I would greatly appreciate it.

So far, I am receiving the following chastisement from the Console:

No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getName() is applicable for argument types: () values: []

Given that we could apply different workflows in this model to different domains piecemeal, it is my hope that custom text in a subsequent mail task could provide appropriate context for the content of these variables. Thanks.

5 Messages

2 years ago

Hi @tyler.bass.tmrhq2.com,

When your workflow is triggered by a start event, you can use the workflow beans to get information about the event. I set a workflow to trigger on asset attribute changed and then changed the description of an asset.

loggerApi.info("Event resource Id: ${event.getEventResourceId().toString()}");
loggerApi.info("Event resource type: ${event.getEventResourceType().toString()}");
loggerApi.info("Event type: ${event.getEventType().toString()}");

Will yield something like

Event resource Id: 79697f25-00d6-4fc7-8069-7efc12d5a36a 
Event resource type: StringAttribute
Event type: ASSET_ATTRIBUTE_CHANGED

From here you can get the asset this attribute belongs to then users assigned to responsibilities, etc. If you just want to notify users of a given change, also consider if the built in email notifications could meet your use case.

10 Messages

Hi, @keegan.shirel.collibra.com,

Customizing this tutorial workflow, I was able to get notifications about the additions of new attribute values or about changes to existing attribute values. Here’s how the “main config” ended up looking in the first script task:

import com.collibra.dgc.core.api.model.instance.attribute.Attribute

def attributeId = event.getEventResourceId()
if(attributeId) {
Attribute attribute = attributeApi.getAttribute(attributeId)
def attributeTypeId = attribute.getType().getId()
def attributeName = attributeTypeApi.getAttributeType(attributeTypeId).getName()
def assetName = attribute.getAsset().getName()
def attributeText = attribute.getValueAsString()
	execution.setVariable("isEmpty", false);
  	execution.setVariable("attributeText", attributeText);	
	execution.setVariable("attributeName", attributeName);
	execution.setVariable("assetName", assetName);
} else {
execution.setVariable("isEmpty", true);
}

The event of an attribute value’s deletion required the “if” statement since the getEventResourceId() bean, should there be no attribute value left over, would have nothing to call on. The tutorial’s workflow template says that that bean “assigns the UUID of the attribute that started the workflow to an attributeId variable.”

How can one call on the attributeName and assetName variables I effectively used above in a different workflow that aspires to socialize removals of attribute values entirely?

Happy Thanksgiving to all.

Best,

Tyler

Cc @arthur.burkhardt and his mountain of Data Citizens Forum frequent flier miles

5 Messages

Hi @tyler.bass.tmrhq2.com - I think you’re looking to record the attribute value and attribute type if it has been deleted. In that case, you’ll want to use the activityStreamApi, as Arthur suggested in his first message.

10 Messages

Hi, Keegan, et al,

So, equipped with these workflow beans to which you have kindly referred me, I am trying to notify users of alterations to a given asset’s status and am having some trouble—particularly, by the look of the console, with isolating the domain name as a variable. The idea of course is that the “Asset Status Changed” start event triggers the workflow. Here is my script task thus far:

def eventType = event.getEventType().toString();
def assetName = item.getName().toString();
def assetId = item.getId().toString();
def domainValue2 = getDomainId(assetId).toString();
def domainValue2Name = domainApi.getDomain(domainValue2).getName();

execution.setVariable('eventType',eventType);
execution.setVariable('assetName',assetName);
execution.setVariable('domainValue2Name',domainValue2Name);

String assetUrl1 = "https://tmrdev.collibra.com/asset/" + ${assetId}
execution.setVariable('assetUrl1',assetUrl1);

The idea is that the variables above could end up in a mail task that includes the following message:
The ${domainValue2Name} asset <b><a href="${assetUrl1}">${assetName}</a></b> has undergone a Status change.

An acceptable subject line would be:
${eventType}: ${domainValue2Name} Asset '${assetName}'

Ideally, the mail task could even articulate the specific status at which the asset has arrived. So far, the Collibra console is advising me that I am missing a method for getDomainId(). If you or anyone else here would happen to have any input, please, I would appreciate that. Thanks.

66 Messages

 • 

1.5K Points

Tyler, I think it is throwing an error because you aren’t calling getDomainId on the item workflow bean.

try replacing def domainValue2 = getDomainId(assetId).toString();

with def domainValue2 = item.getDomainId().toString()

10 Messages

Hi, Sean,

Thanks and sorry. Trying that, I receive a console message informing me that no signature of the method getDomain() is applicable for the following argument types: “(String) values.”

1.2K Messages

2 years ago

Indeed @tyler.bass.tmrhq2.com , the notification workflow is great to get daily notification about all changes.

Here’s a code snippet that does something very close to what you’re looking for. It tracks responsibilities instead of attributes, but it’s the same logic.
https://datacitizens.collibra.com/forum/t/how-to-retrieve-in-a-workwflow-a-user-which-had-been-role-granted/1104/5?u=arthur.burkhardt

Keep in mind that performance is probably going to be horrible though, because the workflow would trigger EVERY SINGLE TIME an attribute is modified.
The daily notification is probably a better approach.

66 Messages

 • 

1.5K Points

2 years ago

@tyler.bass.tmrhq2.com , here is some code that worked for me to get the label and description. I used the FindWorkflowDefinitionsRequest to isolate the current workflow and a business item workflow bean. Cheers!

import com.collibra.dgc.core.api.dto.workflow.FindWorkflowDefinitionsRequest
import com.collibra.dgc.core.api.model.workflow.WorkflowDefinition

def itemName = item.getName() //current item that triggered the workflow
	

def randomWorkflow = workflowDefinitionApi.findWorkflowDefinitions(FindWorkflowDefinitionsRequest.builder()
	.name("Track Attribute Change") //search by Workflow name. You might also want to search by UUID if multiple instances of the workflow will be running.
	.build()
	)
	
List<WorkflowDefinition> allResults = randomWorkflow.getResults()  //call getResults to store the search in a list

WorkflowDefinition currentWorkflowDefinition = allResults.get(0) //calling the first item in the list since I know my search will return one result

execution.setVariable("yourStartLabel",currentWorkflowDefinition.getStartLabel())
execution.setVariable("Your Workflow Description", currentWorkflowDefinition.getDescription())

1.2K Messages

I may be wrong, but I’m not sure that meets the need of the first post. This code queries a workflow instance rather than intercepting workflow events.

Yes, absolutely :+1:
Do a little trial/error since the workflow event interception is not atomic (the code is not blocked to ensure all events have been processed before the code runs). As I said in the post, 1s seems to be a reasonable delay.

66 Messages

 • 

1.5K Points

@arthur.burkhardt, I think if he is only trying to capture the workflow’s start event label and description, the code itself doesn’t need to intercept any workflow events. If this workflow is set to be triggered when an asset attribute is changed, the code is activated in response to a workflow start event. However, he could add more information about the business item which triggered the workflow with the item workflow bean.

1.2K Messages

This is literally the first line of the thread. :wink:

66 Messages

 • 

1.5K Points

I meant to say I set up my example so it was triggered by the “Asset Attribute Changed” Start Event in the Colliibra workflow settings, as you just noted (should have included that detail! ). The script task within the workflow i wrote, doesn’t need workflow beans since he only wanted the workflow’s start label and desc (at least as I could gather from his code block), but if he wanted to link those details to the item that triggered it, he could also use the item bean.

11 Messages

2 years ago

@arthur.burkhardt, in the example that you shared I can see that it was working fine with both Access granted and revoked. I am just wondering if I can use similar approach to keep track of the relations that have been deleted?

21 Messages

2 years ago

Hi guys, coming in from the side here. We are also in need of a workflow that will showcase all assets where responsibilities was adjusted and it sends an email to a specific person to review. This is linked to our ownership model, we would like to see what assets have been updated responsibilities changes. Is there something like this?
@arthur.burkhardt

1.2K Messages

Sure, multiple ways.

  1. Remove responsibility permissions and make a workflow available to reassign resources => You have full control over what happens
  2. Parse the activity log, find all responsibility changes and start workflow instances for all resources where responsibilities have changed.

21 Messages

Thank Arthur, much appreciated. Do you know if there is an existing workflow for this?

1.2K Messages

No, not that I’m aware of

11 Messages

 • 

200 Points

3 months ago

May I please check with you what class is to be imported for this:

def domainValue2Name = domainApi.getDomain(domainValue2).getName()

Thank you!

17 Messages

 • 

1.1K Points

Hi Prashanthi,

import com.collibra.dgc.core.api.component.instance.DomainApi

Please use this.

Thanks,
Paresh

Loading...