Loading...

Populate SharePoint List mulitple choice column with Microsoft 365 Groups-and add some List formatting

Populate SharePoint List mulitple choice column with Microsoft 365 Groups-and add some List formatting

Recently, a customer asked me if I could automagically populate Microsoft 365 Group Names to a multiple choice column in a SharePoint list. Of course I told them that one can create an ootb Person field and allow group selection, but that not quite what they wanted. So I built a simple Power Automate flow that would populate the choice column and and applied some nice list formatting to it.

The Power Automate flow

flow in full

Get your groups

  • We trigger the flow as per our needs (manually, if there is not a lot of change in groups) or on a schedule (if there is a lot of changes in groups)
  • we then initialize a variable (I used string, but you can also do an array) for the groupNames
  • then we use the Azure AD Groups - List Groups action to list all groups. Filter if needed!
  • Then we append the Name (and a comma) in a loop to our groupNames variable

flow first part

Obtain listguid and fieldguid

Now we need to obtain 2 things

  1. the listguid of our SharePoint list: Select the Settings gear ⚙️ on your list, List Settings, you will find it in the URL. The List guid sits right in between %7B and%7D (Of course there are a gazillion of other ways to obtain this, but that is a super easy one)
  2. the fieldguid of the field that we are trying to populate: You can either follow this post here or stick with me and:
  • Use Send an HTTP request to SharePoint
    • Method: Get
    • URI:_api/web/Lists/GetById('@{variables('listGuid')}')/Fields

This will return a massive json object from which you can now find the id of the field you are interested in.

Patch the choice column

As a last step, we just patch our choice column with the groupNames. As we comma-separated the variable, we need to make sure that we remove that comma now:

  • Use Send an HTTP request to SharePoint
    • Method: Patch
    • URI:_api/Web/Lists(guid'listGuid')/Fields(guid'fieldguid')
    • Headers:
      • Accept: application/json;odata=verbose
      • Content-type: application/json;odata=verbose
  • Body:
{
"__metadata": {
"type": "SP.FieldMultiChoice"
},
"FieldTypeKind":15,
"Choices": {'results':[@{substring(variables('groupNames'),0, sub(length(variables('groupNames')),1))}]}
}

send http to SP

If we now check in SharePoint, this already looks good, but I want to improve the experience with some colors.

Some List Formatting

What I want is a refection of which department is selected - remember that this is a multiple choice field? Let’s make that happen! choice column

  • Go tou your list
  • Select the multiple choice field > Column settings > Format this column
  • Select Advanced mode
  • Delete the code in the box
  • Paste in this snippet
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "div",
"txtContent": "=if(indexOf(@currentField, 'Dept-Finance') >= 0, 'Dept-Finance', '')",
"style": {
"display": "inline-block",
"width": "25%",
"background-color": "=if(indexOf(@currentField, 'Dept-Finance') >= 0, '#ffcc99', 'transparent')",
"color": "black",
"text-align": "center",
"padding": "5px"
}
},
{
"elmType": "div",
"txtContent": "=if(indexOf(@currentField, 'Dept-IT') >= 0, 'Dept-IT', '')",
"style": {
"display": "inline-block",
"width": "25%",
"background-color": "=if(indexOf(@currentField, 'Dept-IT') >= 0, '#ccffff', 'transparent')",
"color": "black",
"text-align": "center",
"padding": "5px"
}
},
{
"elmType": "div",
"txtContent": "=if(indexOf(@currentField, 'Dept-HR') >= 0, 'Dept-HR', '')",
"style": {
"display": "inline-block",
"width": "25%",
"background-color": "=if(indexOf(@currentField, 'Dept-HR') >= 0, '#ff9999', 'transparent')",
"color": "black",
"text-align": "center",
"padding": "5px"
}
},
{
"elmType": "div",
"txtContent": "=if(indexOf(@currentField, 'Dept-Marketing') >= 0, 'Dept-Marketing', '')",
"style": {
"display": "inline-block",
"width": "25%",
"background-color": "=if(indexOf(@currentField, 'Dept-Marketing') >= 0, '#b3ffcc', 'transparent')",
"color": "black",
"text-align": "center",
"padding": "5px"
}
}
]
}

How does this list formatting work?

We separate into the number of <div> we need (note this is just an example, there were way more groups to select from) and that set the width to the percentage the <div> may consume. The colors are applied dynamically using indexOf(@currentField, 'Dept-Name') >= 0, which checks if the department is selected in the column. Each part of the cell shows the department name if it is selected. If the department is not selected, the <div> will be empty and have no background color (transparent).

Conclusion

Good old Send and HTTP request to SharePoint saved the day again! No need for app registrations, but a super straight forward flow that populates the multiple choice colum to our needs. Of course you don’t need to do groups, but can apply any array that you fits your use case!

Published on:

Learn more
Luise Freese: Consultant & MVP
Luise Freese: Consultant & MVP

Recent content on Luise Freese: Consultant & MVP

Share post:

Related posts

SharePoint Framework (SPFx) roadmap update – December 2025

SPFx is powering the future of Microsoft 365. From AI-driven portals to seamless integrations across SharePoint, Teams and Viva, SPFx is drivi...

11 hours ago

Exam AB-900: Microsoft 365 Copilot and Agent Administration Fundamentals

Following on the steps of the other AB exams I’ve been writing about my experience with (see Exam AB-730: AI Business Professional &...

14 hours ago

Microsoft Copilot (Microsoft 365): Chat History Landing page: Filtering UI Refresh

To help you quickly find the conversations that matter, we’re updating the Chat History filtering experience. This refresh makes the interface...

15 hours ago

Microsoft Copilot (Microsoft 365): Capture voice notes in the Microsoft 365 Copilot mobile app

With a Microsoft 365 Copilot license, transform offline discussions into structured, actionable, and searchable content with voice notes in Co...

15 hours ago

Microsoft Graph PowerShell SDK V2.34 Makes WAM the Default

The Web Account Manager (WAM) authentication broker becomes the default method for handling interactive Microsoft Graph PowerShell SDK connect...

19 hours ago

Microsoft 365: New functionality and prices in 2026

A range of security and AI enhancements have been announced for the Microsoft 365 suite of products in 2026, along with some small price incre...

1 day ago

Automating Microsoft 365 with PowerShell Update 19

Update #19 of the Automating Microsoft 365 with PowerShell eBook is now available. Subscribers can download the updated PDF and EPUB files fro...

1 day ago

Teams admin center: Auto‑updates for Teams Android device firmware and apps will be paused during year‑end holidays

Auto-updates for Teams Android device firmware and apps via Teams admin center will pause from December 20, 2025, to January 12, 2026, to ensu...

3 days ago

OpenAI’s GPT-Image-1.5 model is now available in Microsoft 365 Copilot

Microsoft 365 Copilot will replace GPT-4o with OpenAI’s GPT-Image-1.5 from mid-December 2025 to late January 2026, enhancing image generation ...

3 days ago

Teams admin center: Messaging safety defaults changing to “On” by default

Starting January 12, 2026, Microsoft Teams will enable messaging safety features by default, including weaponizable file type protection, mali...

3 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy