Page 1 of 1

vb script error on Line 13 "Object Required"

Posted: Tue Mar 28, 2023 4:23 am
by cantoniou
Dim pdV, pdC

' Property IDs on the Vessel object
pdV = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.Vessel")

' The Company property
Dim Compan: Set Compan = CreateObject("MFilesApi.Lookup")
pdC = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.CompanyDocumentCompany")
Set Compan = PropertyValues.SearchForProperty(pdC).TypedValue.GetValueAsLookup()

' Get the ObjID of the company object
Dim ObjIDCompany: Set ObjIDCompany = CreateObject("MFilesAPI.ObjID")
ObjIDCompany.ID = Compan.Item
ObjIDCompany.Type = Compan.ObjectType

' Get the ObjVer of the object
Dim OVCompany : Set OVCompany = CreateObject("MFilesApi.ObjVer")
Set OVCompany = Vault.ObjectOperations.GetLatestObjVer(ObjIDCompany, True)

' Get the property value of the TM property of the vessel
Dim TMPVVessel : Set TMPVVessel = CreateObject("MFilesApi.PropertyValue")
Set TMPVVessel = Vault.ObjectPropertyOperations.GetProperty(OVCompany,pdV)

output.SetValueToLookup TMPVVessel.Value.GetValueAsLookup()

Re: vb script error on Line 13 "Object Required"

Posted: Tue Mar 28, 2023 8:42 am
by Alexander Riedel
You set Compan here:
Set Compan = PropertyValues.SearchForProperty(pdC).TypedValue.GetValueAsLookup()
But you do not check if the statement produces a result that is not null.