vb script error on Line 13 "Object Required"

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.

This forum is a space to discuss coding in VBScript including Windows Script Host, WMI, ADSI, and technical issues related to development.

- Question about a licensed SAPIEN product? Post here: Product Support for Registered Users
- Question about a trial SAPIEN product? Post here: Former and Future Customers - Questions
This topic is 1 year and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
cantoniou
Posts: 1
Last visit: Wed Mar 29, 2023 4:53 am

vb script error on Line 13 "Object Required"

Post 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()
User avatar
Alexander Riedel
Posts: 8600
Last visit: Wed Dec 04, 2024 10:48 am
Answers: 23
Been upvoted: 42 times

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

Post 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.
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 1 year and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked