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()
)
////
arthurburkhardt
·3 years ago · EditedHuh, 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_newandassetMapListis 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.arthurburkhardt
·3 years ago · EditedHuh, 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_newandassetMapListis 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.jeevarekhaag1 G
OP3 years ago · EditedIt works! Thanks…dg