Search code examples
sharepoint-onlinesharepoint-rest-api

Programmatically populate a multi-select field in SharePoint Online via the m365 spo tool


I am trying to create a list item with a multiselect field, according to the m365 spo documentation. It feels like I have tried all possible variations, but I cannot get it to work at all.

Is there any official guide as to the syntax for a multi-select value?


Solution

  • Ok, for whomever bangs their heads against this in the future, the format for the seeds of a multi-lookup field is the following:

    Id;Value;#
    

    Where ;# is the separator. You may use # as a wildcard for a value, ending up with the following example where I am adding the related entities with Id 3 and 5 to the seed:

    3;#;#5;#
    

    or one single entity:

    1;#
    

    or three entities:

    2;#;#3;#;#5;#
    

    There seems to be a tiny bit of tolerance on the trailing value, but I did not experiment much with this.

    PS: it works, and I am very happy, but dear reader know this: if you feel the need for some eye-bleach after reading this, you are not alone!