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)

  • 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)

  • I've tried and it gives me this error.

    CoScriptObjectFactory.cpp, 465, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    ScriptErrorHelper.cpp, 96, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MDispatchExImpl.h, 694, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MDispatchExImpl.h, 997, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataCardAction.cpp, 386, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataCardAction.cpp, 570, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataEditor.cpp, 2967, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataModel.cpp, 4262, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataModel.cpp, 4699, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    ElectronicSignatureUIHelper.cpp, 235, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataModel.cpp, 12176, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    CoVaultMountingDocumentOperations.cpp, 3127, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    DocumentCache.cpp, 11161, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    DocumentCache.cpp, 11270, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    DocumentCache.cpp, 19413, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCMethodCallWithRetry.h, 35, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCMethodCallWithRetry.h, 35, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCDocumentOperations.cpp, 12673, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCDocumentOperations.cpp, 7384, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MCallInLoop.h, 712, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCDocumentOperationsHelper.cpp, 3930, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCDocumentOperationsHelper.cpp, 3468, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCDocumentOperationsHelperPrivate.cpp, 7128, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RecalculateProperties.cpp, 449, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RecalculateProperties.cpp, 449, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    RecalculateProperties.cpp, 1614, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    RecalculateProperties.cpp, 1448, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    RecalculateProperties.cpp, 1681, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    RecalculateProperties.cpp, 1392, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    VaultScriptSessionTemplates.cpp, 269, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    VaultScriptSessionTemplates.cpp, 328, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    VaultScriptSessionTemplates.cpp, 328, Wrong number of arguments or invalid property assignment (0x80040008)
    VaultScriptSessionTemplates.cpp, 501, Wrong number of arguments or invalid property assignment (0x80040008)
    CoActiveScriptSite.cpp, 893, Wrong number of arguments or invalid property assignment (0x80040008)
    CoActiveScriptSite.cpp, 735, Wrong number of arguments or invalid property assignment (0x80040008)
    (VBScript) Opprett telleverk, PropertyDefCalculatedValue, 7, Wrong number of arguments or invalid property assignment (0x80040008)
    MErrorHelper.cpp, 2457, Wrong number of arguments or invalid property assignment (0x80040008)
    (M-Files 20.12.9735.8)

  • Hello, 

    From this error I cannot know what is the issue.

    Maybe you need change other parts of the script also to accomodate the change. 

    If you press details, it will give you the exact line the error occured.

  • Using this method outputs this error.

    It seems that we're trying to read the data the wrong wat maybe?

    CoScriptObjectFactory.cpp, 465, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    ScriptErrorHelper.cpp, 96, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MDispatchExImpl.h, 694, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MDispatchExImpl.h, 997, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataCardAction.cpp, 386, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataCardAction.cpp, 570, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataEditor.cpp, 2967, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataModel.cpp, 4262, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataModel.cpp, 4699, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    ElectronicSignatureUIHelper.cpp, 235, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MetadataModel.cpp, 12176, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    CoVaultMountingDocumentOperations.cpp, 3127, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    DocumentCache.cpp, 11161, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    DocumentCache.cpp, 11270, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    DocumentCache.cpp, 19413, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCMethodCallWithRetry.h, 35, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCMethodCallWithRetry.h, 35, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCDocumentOperations.cpp, 12673, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCDocumentOperations.cpp, 7384, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    MCallInLoop.h, 712, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCDocumentOperationsHelper.cpp, 3930, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCDocumentOperationsHelper.cpp, 3468, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RPCDocumentOperationsHelperPrivate.cpp, 7128, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RecalculateProperties.cpp, 449, Calculation of the automatic value of the property "(VBScript) Opprett telleverk" failed. (0x80040107)
    RecalculateProperties.cpp, 449, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    RecalculateProperties.cpp, 1614, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    RecalculateProperties.cpp, 1448, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    RecalculateProperties.cpp, 1681, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    RecalculateProperties.cpp, 1392, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    VaultScriptSessionTemplates.cpp, 269, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    VaultScriptSessionTemplates.cpp, 328, Script execution failed. (((VBScript) Opprett telleverk, PropertyDefCalculatedValue: 112-203-28)) (0x800408BB)
    VaultScriptSessionTemplates.cpp, 328, Wrong number of arguments or invalid property assignment (0x80040008)
    VaultScriptSessionTemplates.cpp, 501, Wrong number of arguments or invalid property assignment (0x80040008)
    CoActiveScriptSite.cpp, 893, Wrong number of arguments or invalid property assignment (0x80040008)
    CoActiveScriptSite.cpp, 735, Wrong number of arguments or invalid property assignment (0x80040008)
    (VBScript) Opprett telleverk, PropertyDefCalculatedValue, 7, Wrong number of arguments or invalid property assignment (0x80040008)
    MErrorHelper.cpp, 2457, Wrong number of arguments or invalid property assignment (0x80040008)
    (M-Files 20.12.9735.8)

  • 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()