Setting Multi-Value Lookup Field in another list using spjs.utility.updateItem(

Home Forums SPJS-Utility Setting Multi-Value Lookup Field in another list using spjs.utility.updateItem(

Viewing 1 reply thread
  • Author
    Posts
    • #34152
      Mitchell T
      Participant

        I ran into the problem of not being able to set multi-value lookup field using spjs.utility.updateItem() and stumbled upon the solution and wanted to share as I don’t believe this has been addressed.

        Initially I thought something like this would work (but it doesn’t):

        
        
        spjs.utility.updateItem({
            'listName' : 'GUID of list to be updated',
            'id': 'ID value(s) of items to be updated',
            'data' : {
                'MultiValLookupField' : ['ID1', 'ID2', 'ID3']
            }
        )}

        However, this is what actually worked:

        
        
        spjs.utility.updateItem({
            'listName' : 'GUID of list to be updated',
            'id': 'ID value(s) of items to be updated',
            'data' : {
                'MultiValLookupField' : 'ID1;#;#ID2;#;#ID3'
            }
        )}

        I expected the syntax to be similar to setFieldValue() where you can do:

        
        
        setFieldValue('MultiValLookupField' , ['ID1', 'ID2' , 'ID3'])

        but this was not the case, so be aware of this.

      • #34165
        Alexander Bautz
        Keymaster

          Thanks for clarifying this. The format is the same with multiselect lookup columns and multiselect people pickers and the reason for the double ;#;# is that the expected format is like this:

          ID_of_item_1;#Label_of_item_1;#ID_of_item_2;#Label_of_item_2;#

          The label is however not required and therefore can be left empty.

          Alexander

      Viewing 1 reply thread
      • You must be logged in to reply to this topic.