1

I have problems formatting the column of a lookup field with json. Precisely, it is an additional field, displayed from the parent list that I want to format. The lookup field is of type multiple, so I want to loop over all items with forEach.

For reference, this code works on the primary lookup column as a MVP.

 {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
      "elmType": "div",
      "children": [
        {
          "forEach": "choiceIterator in @currentField",
          "elmType": "div",
          "txtContent": "[$choiceIterator.lookupValue]"
        }
      ]
    }

When I use this code on the "additional" column, the column entries are empty. The sharepoint default for this additional column is a semicolon separeted list of all items which I do not like.

0

Unfortunately, after looking into this further, you won't be able to properly work with mulit-value projected fields at this time. While the primary lookup value comes back as an array of objects with the lookupId and lookupValue properties, the projected fields come back as a single string with the semi-colon already inserted. This is super frustrating.

enter image description here

If you use your format above and add the "debugMode":true to the format you'll see the message about this field not being an array (which is required for using the forEach property):

enter image description here

Without the addition of a split operator, or at the very least a substring operator, there is no real way to work with these types of values (at least right now).

  • Thanks for the fast reply. Thats very unfortunate, that this seems to be not possible currently. Interestingly, when I access this secondary lookup column within Flow, I get an array in return that I can loop over to get individual items. – OStetzer Jun 7 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.