Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Getting MedadataDefs in 4.5.1 with VB.NET
JackAtCMG
I have a group of files on a Windows directory which I'm trying to load into MediaBin and attach 3 pieces of custom metadata to the files (Customer Number, Customer ID and Customer Name). We are using MediaBin 4.5.1.
I load all metadata defs into a collection (defined as an MBObjectCollection), and populate the collection with the session.SearchableMetaDataDefinitions.
I sort the collection ByMetaDataDefinitionName and when I loop through the collection to see if the name is equal to one of the 3 pieces I want, it bombs when I hit a piece of non-editable metadata (in this case - Asset Type).
When it bombs it has already gone through 4 or 5 pieces just fine (Asset Category, Asset Description, Asset Name...just to name a couple). When it hits Asset Type (which is NON-Editable) I get an error "13 : Specified Cast is not valid". I also tried populating the collection with "MBSession.DisplayableMetaDataDefinitions" and bomb out with the same thing. The pieces which pass through my collection are Editable, so I'm wondering if there's some way I can just grab the editable metadata pieces.
A guy in my area wrote a similar app a couple years ago against MB 3.0 and was able to specify to populate only Editable metadata to be loaded into his collection. His statement was "Set m_metaDataDefEditable = sessionname.MetaDataDefinitions(EditableMetaData)".
Is there a way in MediaBin 4.5.1 I can specify only editable metadata? I'm thinking there's a method or property I'm not setting correctly because I think this should be a fairly basic operation.
Thanks for your help
Find more posts tagged with
Comments
Konidala
If you are using MBPNetModel use "GetEditableMetadata" method.
If you are using MBScriptModel try the below. It should work
Public Enum MetadataFlags
IsCustom = 0
IsDisplayable = 2
IsEditable = 1
IsSearchable = 3
End Enum
Public Function GetMetadata(ByVal filter As MetadataFlags) As ArrayList
Dim collection As MBPSCRIPTMODEL2Lib.MBObjectCollection = mbSession.DisplayableMetaDataDefinitions
collection.Sort(MBPSCRIPTMODEL2Lib.MBSortField.ByMetaDataDefinitionName, MBPSCRIPTMODEL2Lib.MBSortOrder.MBAscending, Nothing)
Dim enumerator As IEnumerator = collection.GetEnumerator
Dim nameList As New ArrayList
Do While enumerator.MoveNext
Dim objMetadata As Object = enumerator.Current
If CType(objMetadata.GetType.InvokeMember(filter.ToString, System.Reflection.BindingFlags.GetProperty, Nothing, objMetadata, New Object(0 - 1) {}), Boolean) Then
Dim metadataName As String = CType(objMetadata.GetType.InvokeMember("Name", System.Reflection.BindingFlags.GetProperty, Nothing, objMetadata, New Object(0 - 1) {}), String)
nameList.Add(metadataName)
End If
Loop
Return nameList
End Function
Dim editableMetadataNames As ArrayList = GetMetadata(MetadataFlags.IsEditable)
Dim customMetadataNames As ArrayList = GetMetadata(MetadataFlags.IsCustom)
Dim displayableMetadataNames As ArrayList = GetMetadata(MetadataFlags.IsDisplayable)
Dim searchableMetadataNames As ArrayList = GetMetadata(MetadataFlags.IsSearchable)
For your requirement the better way of doing it is create a Task with Runtime parameters & update those 3 metadata values while ingesting the asset into the mediabin.