...
Usecases - Asset metadata update
In the following we show how you can update the different metafield types on an asset.
BIT
Use the Digizuite serviceIAssetSearchService
andIMetadataValueService
.
First we fetch the asset. Then creates a new instance ofBitMetadataUpdate
. TheTargetItemIds
is the itemId of the asset we just fetched. TheMetaFieldItemGuid
is the GUID of the metafield you wants to update. As you can see in the ApplyUpdate, it takes a list of updates. So you have the options to bulk update metadata for an asset.Code Block var assetSearchService = app.Services.GetRequiredService<IAssetSearchService>(); var metadataValueService = app.Services.GetRequiredService<IMetadataValueService>(); var asset = await assetSearchService.GetAsset(75); var bitMetadataUpdate = new BitMetadataUpdate { Value = true, TargetItemIds = new HashSet<int> { asset.ItemId }, MetaFieldItemGuid = Guid.Parse("7072a817-abdf-469b-9042-f281189d52fa") }; await metadataValueService.ApplyUpdate<MetadataUpdate>(new[] { bitMetadataUpdate });
INT
STRING
COMBOVALUE
MULTICOMBOVALUE
DATETIME
TREE
EDITCOMBOVALUE
EDITMULTICOMBOVALUE