Erwan Kerfourn
- Updated
This article has been written to help users participating to the Dalet Flex Challenge 2023 - Challenge number 3 Publish. The configurations described here are not intended to be reproduced in a production environment.
Start by creating a new Script action using the plugin JEF Script .
Begin the script by defining the execute() function. Use the following line of code:
def execute() {
Retrieve the instance metadata of the asset in the context using flexSdkClient.assetService.getAssetMetadata(). You can use the following line of code:
def assetMeta = flexSdkClient.assetService.getAssetMetadata(context.getAsset().id as Long)
Access the acalder-review field within the assetMeta using getField('acalder-review'). This allows you to retrieve the specific field within the metadata. Use the following line of code:
def field = assetMeta.getField('acalder-review')
Set the value of the acalder-review field to "Published" using setValue("Published"). This modifies the value of the field. Add the following line of code:
field.setValue("Published")
Save the modified assetMeta for the asset in the context using flexSdkClient.assetService.setAssetMetadata(). It takes the asset's ID (context.getAsset().id) as a long value and the modified assetMeta as parameters. Add the following line of code:
flexSdkClient.assetService.setAssetMetadata(context.getAsset().id as long, assetMeta)
Finally, close the execute() function by adding the following line of code:
}
In summary, this script retrieves the metadata of an asset, updates the value of the acalder-review field to "Published", and saves the modified metadata back to the asset in the context.
def execute(){
def assetMeta = flexSdkClient.assetService.getAssetMetadata(context.getAsset().id as Long)
assetMeta.getField('acalder-review').setValue("Published")
flexSdkClient.assetService.setAssetMetadata(context.getAsset().id as long, assetMeta)}
Comments
0 comments
Please sign in to leave a comment.