U

4 Messages

 • 

1.3K Points

Wednesday, May 1st, 2024 11:09 AM

Workflow to copy assets from Domain A to Domain B, retaining all attributes and relations

Hi All,

I would expect help for requirement for workflow to copy assets from Domain A to Domain B, retaining all attributes and relations and without deleting assets from source domain.

@laurenzhiller1  @arthurburkhardt

Accepted Solution

26 Messages

 • 

1.8K Points

8 months ago

def newAssetUuid = assetApi.addAsset(AddAssetRequest.builder() // Creates new asset in domain New Business Term in community Data Governance Council
	.name(assetDisplayName)
	.displayName(assetDisplayName)
	.typeId(assetType)
	.domainId(string2Uuid("00000000-0000-0000-0000-000000006013"))
	.build()).getId();


def cloneAttribute = "";
def attributeStringValue = "";
		
//Get and clone attributes to newly created asset
def attributes = attributeApi.findAttributes(FindAttributesRequest.builder().assetId(item.getId()).build()).getResults();
	for (attribute in attributes.sort { it.getType().getName() }) {
		attributeStringValue = attribute.getValue()
		cloneAttribute = attributeApi.addAttribute(AddAttributeRequest.builder().assetId(newAssetUuid).typeId(attribute.getType().getId()).value(attributeStringValue).build())
	};

4 Messages

 • 

1.3K Points

@bbaric  Thanks a lot, the code works fine. Also the workflow has to be triggered every week to copy assets, but when the workflow is triggered again then I encounter the below error:
"An asset with signifier 'test1' already exists for domain 'B'."
Any suggestions to avoid it?

26 Messages

 • 

1.8K Points

You can make a counter that will increment numbers so you don't have assets with the same names in the domain.

def assetDisplayName = test + counter;
Loading...