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

Copy item from single-select to multi-select.

Former Member
Former Member
Hello, this is my first post, so thanks up front for whatever help anyone can give, and sorry for my lack of knowledge.

I am trying to copy the selection in a single-select property (iRollNumberProperty) to the selection in a multi-select property (iLandIDProperty) on the same object. The properties pull from two different Object Types which use identical queries to pull from the same external source (so, the unique IDs are the same in both Object Types).

I borrowed the AddUpdateProperty function from another topic, and used it without modification. The code is in the automatic value of an unrelated field.

I have used one specific case (129203000) to troubleshoot. The idea is to add the objectID "129203000" to the Land ID property to the object I was using as a test. When I trigger it, I get the error message that is attached. 344 is the ID of the Land ID object type, which is where the property value should be pulled from.

Hopefully my code will fill in the gaps where my explanation may be lacking. This is M-Files 2015.3.

Thanks.



Option Explicit

Dim iRollNumberProperty : iRollNumberProperty = 1432 '1432 is the Roll Number Property Definition
Dim iLandIDProperty : iLandIDProperty = 1747 '1747 is the LandID Property Definition
Dim objClientLookup: Set objClientLookup= PropertyValues.SearchForProperty(iLandIDProperty).TypedValue.GetValueAsLookup()

if IsNull(PropertyValues.SearchForPropertyEx(iLandIDProperty, true))=False then

    dim iRolls: iRolls = 129203000
    AddUpdateProperty iRolls, iLandIDProperty

end if


Function AddUpdateProperty(sValue, PROP_ID)

Dim oProperty : Set oProperty = CreateObject("MFilesAPI.PropertyValue")
oProperty.PropertyDef = PROP_ID
Dim iDataType : iDataType = Vault.PropertyDefOperations.GetPropertyDef(oProperty.PropertyDef).DataType
Dim iValue : iValue = CLng(sValue)
Dim oLookups : Set oLookups = PropertyValues.SearchForProperty(PROP_ID).TypedValue.GetValueAsLookups()
Dim oLookup : Set oLookup = CreateObject("MFilesAPI.Lookup")
Dim oCount

oCount = oLookups.Count
If oCount <> 0 then oCount = oCount + 1
oLookup.Item = iValue
oLookups.Add oCount, oLookup
PropertyValues.SearchForProperty(PROP_ID).TypedValue.SetValueToMultiSelectLookup oLookups
oProperty.TypedValue.SetValueToMultiSelectLookup oLookups
Vault.ObjectPropertyOperations.SetProperty ObjVer, oProperty
End Function
  • Thank you for the a very usefull script, this is what I was looking for a long time!
    Can anybody please help and point me in a direction of a script that does the same thing but with 2 - multi-select properties?
    Take all the data from 1 multiselect property and insert them to 2 multiselect property. I tried the option 2 code, but I get an error "Too many lookups"

    P.S.
    Got my answer from post community.m-files.com/index.php
    Just needed to modify the GetValueasLookups with s on the and and modify the setValue command.

    Dear Clbeech
    There is a way to clear a property using a command
    Value.SetValueToNULL
    I have not tested it, but it should look something like

    Option Explicit
    CONST LAND_ID_PD = 1747 'Multi select where to copy to
    dim LandIDPV: set LandIDPV = PropertyValues.SearchForPropertyEx(LAND_ID_PD, true) ' define the property
    LandIDPV.Value.SetValueToNULL ' set the value to NULL

    Then run the option 2 and the list should be populated.