Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
revisemetadata - throws exception
ushapriya
Hi
I tried to edit one metadata field for an asset ( asset is of type MBAsset, server is MediaBinServer object )
Dim mdata() As MBMetadata
mdata = asset.metadata
For i = 0 To mdata.Length - 1
Response.Write(mdata(i).mName & " " & mdata(i).mValue)
If mdata(i).mName = "Picture title" Then
mdata(i).mValue = "employee"
End If
Response.Write(mdata(i).mName & " " & mdata(i).mValue)
Next
server.ReviseAssetMetadata(asset.mID, mdata)
I get the following exception - Server was unable to process request. --> MBException: The type must match the original. (0x80040449)
If i do not use the revise assetmetadata, the value of the editable metadata is fine within the context of the page, once out of page context, the value is not updated on the Asset. I would think this is by design. However, I am unable to debug any further.
Any help would be appreciated.
Thank you
-usha
Find more posts tagged with
Comments
msnider
First, if you are only revising one piece of metadata, then you don't need to send the entire array....just a single element array containing the metadata you want to edit.
Second, the list of metadata returned with an MBAsset object is a "displayable" list, in other words certain types of metadata values are converted from their native type to a displayable string value...e.g. booleans are converted from true\false to Yes\No, but the ReviseAssetMetadata call is expecting a boolean. In your case, a string value is just a string value, but since you are passing the entire metadata array back then there is probably another metadata element that contains a converted value which results in the exception.
Also, custom metadata info like name and ID are global to the server so if you know the exact metadata that you want to add or edit you don't need to get the asset and then iterate over it's metadata list. All you would need is the asset ID and the metadata ID. To get the metadata's ID, you can use GetEditableMetadata to retrieve a list of all the server's editable metadata.
Your code should look something like this:
MBMetadata[] metadataArray = new MBMetadata[1];
metadataArray[0] = new MBMetadata();
//Add an Author metadata
metadataArray[0] .mName = "Author";
metadataArray[0] .mID = "{E94A2180-582A-11D4-8104-0050DA27F4FC}";
metadataArray[0] .mValue = "Hawthorne";
server.ReviseAssetMetadata( assetID, metadataArray );
Hope this helps,
Mark
ushapriya
Thank you Mark. That was very helpful.
Following up with "DisplayableMetadata" for asset -
How can i get the metadatavalue if the metadata is not displayable for the asset but value exists ?
Thank you in advance.
Usha
msnider
I don't quite understand your question. If the metadata is not displayable, how do you know it has a value? Do you mean to say how do you get the value for a metadata that is not displayable to a specific user because of how its permissions are set up?
Mark
ushapriya
The pages run under NT User context, but we want to change metadata information if the user performed the download. This is when the metadata is not displayable but needs to be edited - scenario.
This was the reply from MEDIA BIN consultant -
"Yeah, that's an issue that we'll have to resolve somehow. I've done a quick canvass of the engineering staff, and the consensus is that there are two main ways you could deal with this -- one would be to have the ASP code update a text file with the asset GUID, and have a VBScript running under an admin user login on a scheduled basis every few minutes to check which assets have been downloaded and to increment the metadata value there. The other would be to modify the metadata edit pages so that the download count field is non-editable regardless of what the permissions on the field are. Let me know whether you think either of those approaches would work for you and if you have questions about the specifics of implementing that."
Instead of the above approaches, we tracked these values in the database and changed the download.asp and download_utils.asp.