Accesing variable form reference object VB Script

Hey, I'm triyng to access a property that is in chose from list Object. Im getting "Object required: '1' ". as an error.  Thank you in advance for your help. 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
Option Explicit
Dim postavke
postavke = PropertyValues.SearchForProperty(1283).TypedValue.GetValueAsLookup.Item
Dim uvjet : uvjet = Vault.ObjectPropertyOperations.GetProperties( postavke.ToObjVer(), True )
If uvjet.SearchForProperty(1282).TypedValue.DisplayValue = "Yes" Then
AllowStateTransition = True
Else
AllowStateTransition = False
End If
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • I wrote a long response to this yesterday but it looks like I lost it.  That's really unfortunate.

    The issue here is the fact you're converting from a Lookup to an ObjVer.

    A lookup is a pointer to another object in the system.  Most of these lookups are version-independent; they point to a particular object, not a particular object version.  Consider a common situation of a document pointing to a customer - the relationship is to the customer, not to a particular version of that customer.

    Version-specific lookups do exist.  If you look at the lookup class you'll see that it can contain a version.  These are useful in specific situations.  For example: consider a case where you provided a document to an auditor as part of an audit; in that case it's useful to know not only which document, but also which version of the document.

    So the "GetAsObjVer" method will literally take the data in the lookup - the object id, type, and version if there is one - and return it as that different structure.  If the lookup is version-independent then it will return -1 to show that.

    Unfortunately most of our API methods require you to provide the exact version of the object when performing actions such as retrieving properties.  The API methods do not unfortunately automatically convert -1 to the latest version.  This is by design; operations that take an ObjVer need the version data, but operations that take an ObjID do not.

    If you want to use GetAsObjVer, as an example, then you need to have some code that deals with the fact that the lookup may not return a version number.  If it does not then you have to go back to the server and ask for the latest version before you use it.

  • Thanks to both of you for the clarification. Maybe, your explanation can be included in the M-Files API manual.

1 2