Trigger a workflow when a specific relation type value is removed or added in a domain.
Hi,
Is there a way I can trigger a workflow only when a related asset value of particular relation type is removed or added for an asset in domain?
Collibra DGC Version - 5.6.4
Former User
Posted 5 years ago · Edited 1 year ago·Last reply 5 years ago
4 comments
arthurburkhardt
·5 years ago · EditedStart events are made for that, indeed

edit: if you want to only apply for a specific relationtype, you should check that in the workflow itself: Terminate if not the right type, or continue process if right relation type. Be careful this might lead to performance issues if you have a lot of relations
Former User
OP5 years ago · EditedThanks Arthur,
Following code worked for me:
import com.collibra.dgc.core.api.dto.meta.relationtype.FindRelationTypesRequest
import java.util.*
boolean continueWorkflow = false;
//Get relation between the Source and Target Asset Type
requiredRelationTypeId = relationTypeApi.findRelationTypes(FindRelationTypesRequest.builder()
.sourceTypeName(“Source Asset Type”)
.targetTypeName(“Target Asset Type”)
.build())
.getResults().get(0).getId()
loggerApi.info("******* requiredRelationTypeId: ${requiredRelationTypeId}")
//Get the occured event resource ID
changedRelationId = event.getEventResourceId()
loggerApi.info("******* changedRelationId: ${changedRelationId}")
//Check if required relation was modified
String error = null
try{
changedRelationTypeId = relationApi.getRelation(changedRelationId).getType().getId();
loggerApi.info("******* changedRelationTypeId: ${changedRelationTypeId}")
}catch(Exception e) {
error = e.getMessage()
loggerApi.info("******Exception: ${error.toString()}")
}
if(error==null && changedRelationTypeId==requiredRelationTypeId){
continueWorkflow = true;
}else if(error.contains(“relationNotFound”)){
continueWorkflow = true;
}
execution.setVariable(“requiredRelationTypeId”, requiredRelationTypeId)
execution.setVariable(“continueWorkflow”, continueWorkflow)
arthurburkhardt
·5 years ago · EditedCool that it worked for you!
Also, I would probably suggest to hardcode the type you are looking for.
If you have different IDs between environments, just declare the IDs as part of readable=false variables in the user start form, this is the Collibra best practice.
Former User
OP5 years ago · EditedYes, you are right.
Thanks again!