Check User Account exists on another object

Hi, I need to use some workflow state action script to validate if a selected 'Owner' is listed in an Organisation


Organisations are tagged with 'M-Files User' property, which is a multi-select from the User account value list

The workflow process objects we're creating will be have a single-select 'Owner' property, which is again selecting from the User account value list


Normally I'd do this in script with something like this code:

 

' Get all the Organisations from the Delivery Team
Dim OrgLOOKUPS : Set OrgLOOKUPS = DTPropVal.SearchForProperty(pOrg).TypedValue.GetValueAsLookups

' Start Organisation lookups 
Set OrgObjID = CreateObject("MFilesAPI.ObjID")
OrgObjID.Type = otOrganisation

' Get details for each Organisation 
Dim Orglookup : Set Orglookup = CreateObject("MFilesAPI.Lookup")
Dim OrgObjVer : Set OrgObjVer = CreateObject("MFilesAPI.ObjVer")
Dim OrgPropVal : Set OrgPropVal = CreateObject("MFilesAPI.ObjectVersionAndProperties") 

For Each Orglookup in OrgLOOKUPS
	If Orglookup.item = SelectedOrg Then
		IsOwnerInDT = 1
		Exit For ' Stop the For loop, a match has been found
	End If
Next 

But the problem is on line6, where I'd define the Object Type of my lookup - I can't do this with Users as they're not objects, they're entries in the Value List

How would I do this, instead then?
Many thanks

Parents
  • If this is your full script, you can simply drop lines 5 and 6. OrgObjID is not used later in this part of the script.

    ObjID.Type is always a number (long), not a string as you have put it in line 6.

    Value lists have a Type ID (value list ID) in the same number series as Object types. You should be able to hard code that ID in your script or to give the value list an Alias and then use the GetValueListIDByAlias method to find the ID.

Reply
  • If this is your full script, you can simply drop lines 5 and 6. OrgObjID is not used later in this part of the script.

    ObjID.Type is always a number (long), not a string as you have put it in line 6.

    Value lists have a Type ID (value list ID) in the same number series as Object types. You should be able to hard code that ID in your script or to give the value list an Alias and then use the GetValueListIDByAlias method to find the ID.

Children
No Data