diff --git a/.frontmatter/database/mediaDb.json b/.frontmatter/database/mediaDb.json index 68ea569152..433e00bd4a 100644 --- a/.frontmatter/database/mediaDb.json +++ b/.frontmatter/database/mediaDb.json @@ -1 +1 @@ -{"users":{"luise":{"onedrive":{"dev":{"pnpblog":{"content":{"weekly-agenda":{"23-09-11":{"images":{"weeklyagenda37.png":{}}},"23-09-18":{"images":{"weeklyagenda38.png":{}}},"23-10-16":{"images":{}},"23-10-23":{"images":{}},"23-10-30":{"images":{}},"23-11-06":{"images":{}},"23-11-13":{"images":{}},"23-11-20":{"images":{}},"23-11-27":{"images":{}},"23-12-04":{"images":{}},"23-12-11":{"images":{}},"23-12-18":{"images":{}},"23-12-25":{"images":{}},"24-01-01":{"images":{}},"24-01-08":{"images":{}},"24-01-15":{"images":{}},"24-01-22":{"images":{}},"24-01-29":{"images":{}},"24-02-05":{"images":{}},"24-02-12":{"images":{}},"24-02-19":{"images":{}},"24-02-26":{"images":{}},"24-03-04":{"images":{}},"24-03-11":{"images":{}},"24-03-18":{"images":{}},"24-03-25":{"images":{}},"24-04-01":{"images":{}},"24-04-08":{"images":{}},"24-04-15":{"images":{}},"24-04-22":{"images":{}},"24-04-29":{"images":{}},"24-05-06":{"images":{}},"24-05-13":{"images":{}},"24-05-20":{"images":{}},"24-05-27":{"images":{}},"24-06-03":{"images":{}},"24-06-10":{"images":{}},"24-06-24":{"images":{}},"24-07-01":{"images":{}},"24-07-08":{"images":{}},"24-07-15":{"images":{}},"24-07-22":{"images":{}},"24-07-29":{"images":{}},"24-08-05":{"images":{}},"24-08-26":{"images":{}},"24-09-02":{"images":{}},"24-09-09":{"images":{}},"24-09-16":{"images":{}},"24-09-23":{"images":{}},"24-09-30":{"images":{}},"24-10-07":{"images":{}}}}}}}}}} \ No newline at end of file +{"users":{"luise":{"onedrive":{"dev":{"pnpblog":{"content":{"weekly-agenda":{"23-09-11":{"images":{"weeklyagenda37.png":{}}},"23-09-18":{"images":{"weeklyagenda38.png":{}}},"23-10-16":{"images":{}},"23-10-23":{"images":{}},"23-10-30":{"images":{}},"23-11-06":{"images":{}},"23-11-13":{"images":{}},"23-11-20":{"images":{}},"23-11-27":{"images":{}},"23-12-04":{"images":{}},"23-12-11":{"images":{}},"23-12-18":{"images":{}},"23-12-25":{"images":{}},"24-01-01":{"images":{}},"24-01-08":{"images":{}},"24-01-15":{"images":{}},"24-01-22":{"images":{}},"24-01-29":{"images":{}},"24-02-05":{"images":{}},"24-02-12":{"images":{}},"24-02-19":{"images":{}},"24-02-26":{"images":{}},"24-03-04":{"images":{}},"24-03-11":{"images":{}},"24-03-18":{"images":{}},"24-03-25":{"images":{}},"24-04-01":{"images":{}},"24-04-08":{"images":{}},"24-04-15":{"images":{}},"24-04-22":{"images":{}},"24-04-29":{"images":{}},"24-05-06":{"images":{}},"24-05-13":{"images":{}},"24-05-20":{"images":{}},"24-05-27":{"images":{}},"24-06-03":{"images":{}},"24-06-10":{"images":{}},"24-06-24":{"images":{}},"24-07-01":{"images":{}},"24-07-08":{"images":{}},"24-07-15":{"images":{}},"24-07-22":{"images":{}},"24-07-29":{"images":{}},"24-08-05":{"images":{}},"24-08-26":{"images":{}},"24-09-02":{"images":{}},"24-09-09":{"images":{}},"24-09-16":{"images":{}},"24-09-23":{"images":{}},"24-09-30":{"images":{}},"24-10-07":{"images":{}}},"post":{"how-to-populate-sharepoint-list-multiple-choice-column-with_m365-groups.md":{"images":{}}}}}}}}}} \ No newline at end of file diff --git a/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-details-sp.png b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-details-sp.png new file mode 100644 index 0000000000..90d33995c5 Binary files /dev/null and b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-details-sp.png differ diff --git a/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-full.png b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-full.png new file mode 100644 index 0000000000..f8803fd969 Binary files /dev/null and b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-full.png differ diff --git a/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-groups.png b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-groups.png new file mode 100644 index 0000000000..bbeb9ae2a3 Binary files /dev/null and b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-groups.png differ diff --git a/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-sp.png b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-sp.png new file mode 100644 index 0000000000..5f2bbbcf08 Binary files /dev/null and b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/flow-sp.png differ diff --git a/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/lego-list.png b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/lego-list.png new file mode 100644 index 0000000000..b6aab7d669 Binary files /dev/null and b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/lego-list.png differ diff --git a/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/sp-choice.png b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/sp-choice.png new file mode 100644 index 0000000000..dd24464c71 Binary files /dev/null and b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/images/sp-choice.png differ diff --git a/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/index.md b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/index.md new file mode 100644 index 0000000000..1ac57b62a3 --- /dev/null +++ b/content/post/how-to-populate-SharePoint-List-multiple-choice-column-with_m365-groups.md/index.md @@ -0,0 +1,87 @@ +--- +title: Populate SharePoint List multiple choice column with Microsoft 365 Group names +date: 2024-10-04T09:34:21.073Z +author: Luise Freese +githubname: LuiseFreese +categories: + - Community post +images: + - images/lego-list.jpg +tags: + - SharePoint + - Power Automate +type: regular +description: In this article you will learn how to populate a SharePoint List multiple choice colum with M365 Group names +--- + +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 was not quite what they wanted. So I built a simple Power Automate flow that would populate the choice column and applied some nice list formatting to it. + +## Prerequisites + +- Have a SharePoint list +- Create a Choice column (I named mine `Group`) +- Under **More options** flip the switch **Allow multiple selections** to `Yes` + +## The Power Automate flow + +![flow in full](images/flow-full.png) + +We will use non-Premium connectors, first leveraging the Azure AD Group connector (*time for a rename @Microsoft, huh?*) to get all the groups, then use the SharePoint connector to send a request via SharePoint REST API. Let's get started! + +### 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](images/flow-groups.png) + +### 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). If you like to, write this value into a variable - it looks just more neat and tidy! +2. the **fieldguid** of the field that we are trying to populate: You can either follow [this post here](https://medium.com/@hadimahmood777/sharepoint-essentials-getting-to-know-your-lists-column-guid-a7b46bdf7596) 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. Again, use a variable if you like to! + +If you need this for several multiple choice columns, I suggest that you filter down your `results` array to the column that you are interested in and then select the `id` from that. + +### Patch the choice column + +As a last step, we patch our choice column with the groupNames. As we comma-separated this variable, we need to make sure that we remove that comma now: + +![send http to SP](images/flow-sp.png) + +- 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**: + +```json +{ +"__metadata": { +"type": "SP.FieldMultiChoice" +}, +"FieldTypeKind":15, +"Choices": {'results':[@{substring(variables('groupNames'),0, sub(length(variables('groupNames')),1))}]} +} +``` + +If we now check in SharePoint, this looks good! Next time: Add some Listformatting to the column! + +## Sneak peek + +![sneak peak list formatting](images/sp-choice.png) + +Let me if you like it :-) + +