This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

VBScript Set a property that isnt on a class

I want to use the BeforeCreateNewObjectFinalize Event Handler to setup a Empty property that isnt on a certain class.

Here is a example how i did it:


Option Explicit

Const I_OBJTYPE = 0

If ObjVer.Type = I_OBJTYPE Then

PropertyValues.SearchForProperty(1300).TypedValue.SetValue MFDatatypeText, ""
Vault.ObjectPropertyOperations.SetAllProperties ObjVer, true, PropertyValues

End If

This script works fine if the property is already on the class itself while creating. But the main functionality should be here to set the property 1300 on the class and set the empty value. Like i would use "Set Properties" on the WF State, but that isnt a solution because it sets a empty value everytime i revide the document.

Parents
  • Update regarding this.

    I actually need now just a check if a property exists or is null. 

    Option Explicit
    
    Dim propCheck
    propCheck = PropertyValues.SearchForProperty(1300).TypedValue
    
    Const I_OBJTYPE = 0
    
    IF propCheck is NULL or Empty Then
    'do Nothing
    
    ELSEIF ObjVer.Type = I_OBJTYPE Then
    
    'Set Property Value As Empty
    PropertyValues.SearchForProperty(1300).TypeValue.SetValue MFDatatypeText, ""
    Vault.ObjectPropertyOperations.SetAllProperties ObjVer, true, PropertyValues
    
    END IF

    The problem is already at start in line where it reads Value of "propCheck". I want to read that value so it can be read as non existing or null.

  • I'm communicating with myself. Slight smile

    Here is the fix for that script:

    Option Explicit
    
    Dim propCheck, propCheckTest
    'propCheck = PropertyValues.SearchForProperty(1300).TypedValue
    propCheck = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.OriginalDocumentName")
    set propCheckTest = PropertyValues.SearchFOrPropertyEx(propCheck, true)
    Const I_OBJTYPE = 0
    
    IF propCheckTest is Nothing Then 
    'do Nothing
    ELSEIF ObjVer.Type = I_OBJTYPE Then      
          'Set the property value as empty
          PropertyValues.SearchForProperty(1300).TypedValue.SetValue MFDatatypeText, ""
    END IF

    I didnt need the line Vault.ObjectPropertyOperations.SetAllProperties ObjVer, true, PropertyValues.

    Now its all working fine.

Reply
  • I'm communicating with myself. Slight smile

    Here is the fix for that script:

    Option Explicit
    
    Dim propCheck, propCheckTest
    'propCheck = PropertyValues.SearchForProperty(1300).TypedValue
    propCheck = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.OriginalDocumentName")
    set propCheckTest = PropertyValues.SearchFOrPropertyEx(propCheck, true)
    Const I_OBJTYPE = 0
    
    IF propCheckTest is Nothing Then 
    'do Nothing
    ELSEIF ObjVer.Type = I_OBJTYPE Then      
          'Set the property value as empty
          PropertyValues.SearchForProperty(1300).TypedValue.SetValue MFDatatypeText, ""
    END IF

    I didnt need the line Vault.ObjectPropertyOperations.SetAllProperties ObjVer, true, PropertyValues.

    Now its all working fine.

Children
No Data