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

Getting a value from a MultiSelect lookup

Hey guys, I have a script within a object called "Machine" that creates a record every time the object is edited.

The record is created as a separate object called "Machine records".

Within these two objects there is a property called "Customer" that is a single select type, its list of the object type "Customers".

In the script pasted below I've showed an example of how I create the record object, and simply copying the value customer ID from one object to another.

But the customer has changed their mind and want to use the built in multi select property for "Customer", now how do I transform the code below from the single select property, to using the multiselect property?

I've tried different methods with now luck..

'Some code

'Getting the customer id from the current object
Dim kundeID
kundeID = PropertyValues.SearchForProperty(1040).Value.GetLookupID() 'This is single select

' Some other 

'Creating the record object 

'More code

'Populating the customer property in the record object
oOnePropVal.PropertyDef = 1040
oOnePropVal.TypedValue.SetValue MFDatatypeLookup, kundeID
oPropVals.Add -1, oOnePropVal

'Calling the create function
Call Vault.ObjectOperations.CreateNewObjectEx(iOTCollation, oPropVals, oFiles, False, True, oACL)

Parents
  • Hello,

    I think it should be something like this:

    'Getting the customer id from the current object
    Dim kundeID
    kundeIDs = PropertyValues.SearchForProperty(1040).TypedValue.GetValueAsLookups()
    Dim kundlelist : Set kundlelist  = CreateObject("MFilesAPI.LookUps")
    
    for each kundeID in kundeIDs
    
    kundelist.Add -1, kundeID
    Next
    
    ' Some other 
    
    'Creating the record object 
    
    'More code
    
    'Populating the customer property in the record object
    oOnePropVal.PropertyDef = 1040
    oOnePropVal.TypedValue.SetValueToMultiSelectLookup kundelist
    oPropVals.Add -1, oOnePropVal
    
    
    'Calling the create function
    Call Vault.ObjectOperations.CreateNewObjectEx(iOTCollation, oPropVals, oFiles, False, True, oACL)

  • Thanks man, this worked, 

    The only thing I needed to change was to add "Set" to the "kundeIDs":

    Dim kundeIDs
    Set kundeIDs = PropertyValues.SearchForProperty(1032).TypedValue.GetValueAsLookups()

Reply Children
No Data