VBScript to check if a property exists on an object

Hi, I want to check if a property exists on a document, and if it's blank 

To find if the property is blank, then I can do something like this: 

If Vault.ObjectPropertyOperations.GetProperty(ObjVer, pStatusCode).TypedValue.IsNull Then
Or
If PropertyValues.SearchForProperty(pStatusCode).TypedValue.IsNULL() Then


Or if i have the value, then
If IsNull(szStatusCode) Then
Or
If szStatusCode = "" Then

However, these will all fail if the property doesn't exist on the object at all
How can I check if a property is on an object?

Many thanks 

Parents
  • I tend to like "indexof", personally.  Something like:

    Dim pStatusCodeIndex
    pStatusCodeIndex = PropertyValues.IndexOf(pStatusCode)
    
    If pStatusCodeIndex = -1 Then
      ' Property not on this object
    Else
      ' Property is on this object
    End If

    Note that the above does not deal with the situation where the property definition exists but has no value; this is simply to check whether the property values collection contains an entry for the definition or not.

Reply
  • I tend to like "indexof", personally.  Something like:

    Dim pStatusCodeIndex
    pStatusCodeIndex = PropertyValues.IndexOf(pStatusCode)
    
    If pStatusCodeIndex = -1 Then
      ' Property not on this object
    Else
      ' Property is on this object
    End If

    Note that the above does not deal with the situation where the property definition exists but has no value; this is simply to check whether the property values collection contains an entry for the definition or not.

Children