9 Messages
Adding multiple assets with multiple attributes from excel file
I am creating a workflow to add 2 different kind of attributes while creating an asset. I am getting all this asset and attribute values from an excel sheet. But I am unable to get the asset Id of the new asset for adding the attribute. Please find the below code which I have tried,
for(assetMap in assetMapList){
addAssetList.add(AddAssetRequest.builder()
.name(assetMap.assetName)
.domainId(string2Uuid(assetMap.domainId))
.typeId(string2Uuid(assetMap.assetTypeId))
.build()
)
addAttributeList.add(AddAttributeRequest.builder()
.assetId(string2Uuid(assetMap.assetName.getId()))
.typeId(string2Uuid(assetMap.attributeType1))
.value(assetMap.attributeValue1)
.build()
)
addAttributeList.add(AddAttributeRequest.builder()
.assetId(string2Uuid(assetMap.assetName))
.typeId(string2Uuid(assetMap.attributeType2))
.value(assetMap.attributeValue2)
.build()
)
////
//def assets_new = assetApi.addAssets(addAssetList)
//loggerApi.info("assets_new: ${assets_new}")
////
}
arthurburkhardt
1.2K Messages
2 years ago
Huh, interestingly I never noticed that “AddAssets” methods, I only used the AddAsset method.
Well, it returns
List<Asset>
, so you can use it to enrich your list.I don’t really understand why you write
assetMap.assetName.getId()
, it’s not very clear what is in your assetMap. Are you copying assets from one domain to anotherAnyways:
assetApi.addAssets(addAssetList)
, so you should split your iteration in two (one for assets, one for attributes)assets_new
andassetMapList
is based on the name of the asset which must be unique. So you could index a new map based on assets_new, using the name as the key.1
0