{"id":110927,"date":"2018-03-22T04:32:39","date_gmt":"2018-03-22T11:32:39","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/"},"modified":"2018-03-22T04:32:39","modified_gmt":"2018-03-22T11:32:39","slug":"fotw-members-your-office365-groups","status":"publish","type":"power-automate","link":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/","title":{"rendered":"Advanced | Flow of the Week: Get an email with the members of your Office 365 groups"},"content":{"rendered":"

Are you the owner of an Office 365 group that anyone can join, but you still want to, at a glance, understand who is on the group and get some details about them? This flow is for you!<\/p>\n

For this scenario, we\u2019ll create a Button flow that collects a search term from you. It will then find all of the Office 365 groups you own that contain that search term, and list the users for each of those groups. You\u2019ll then get an email with a table of all of the users in each of those groups, along with some details about those users.<\/p>\n

This flow will demonstrate some advanced concepts, including appending to a string variable<\/strong>, building an HTML email<\/strong>, and nested Apply to each<\/strong>.<\/p>\n

Starting the Flow<\/h2>\n

The flow will start out simple with a Button<\/strong> trigger.<\/p>\n

\"\"<\/p>\n

On the Button trigger, we\u2019ll have one input to collect a search term. Next, we\u2019ll List my owned groups<\/strong> in the Office 365 Groups connector \u2013 and then use Filter array<\/strong>. In the Filter array, on the left side use Add Dynamic Content<\/strong> to find the Name<\/strong> of the group. Use the contains<\/em> operation in the middle, and then use Add Dynamic Content to find the input field you added in the Button trigger. This will return an array that only contains Office 365 Groups which contain the search term you\u2019ll enter when you run the button.<\/p>\n

Using a string variable<\/h2>\n

We will build the HTML email by creating a string variable \u2013 a variable is an easy way to collect data each time an action happens inside of a loop. Whenever you use a variable, first you need to use the Initialize variable<\/strong> action. You can name your variable whatever you like, but you need to be sure to set the Type as String.<\/p>\n

\"\"<\/p>\n

The first loop we are going to create is over each of the Office 365 groups returned by the Filter array<\/strong> action. To add this, select New step<\/strong> and then More<\/strong> and Apply to Each<\/strong>. Add dynamic content for the Select an output from previous steps<\/strong>, and you\u2019ll see the original list of groups from the first action, and the filtered list of groups from the Filter array <\/strong>action. Select that list.<\/p>\n

\"\"<\/p>\n

Inside the Apply to each we are going to start constructing the email. For each group we\u2019ll add a heading and the description by using the Append to string variable <\/strong>action. All you need to do is select the variable you created earlier, and then include the content that you want, such as the displayName of the group. Also, for the next step add a new <table> tag at the bottom of the variable.<\/p>\n

\"\"<\/p>\n

Getting the group members<\/h2>\n

Now that you\u2019ve started creating the email, you\u2019ll need to actually retrieve the members of the group. Use the List group members<\/strong> action. In the Group Id<\/strong> field, do not select one of the items in the dropdown, but go to Enter custom value <\/strong>instead. This allows you to Add dynamic content<\/strong> and select the Group Id <\/strong>from the Filter array action (you should search in the Dynamic content window to find this).<\/p>\n

\"\"<\/p>\n

Add the second Apply to each loop like you added the first, but this time select the list from the List group members<\/strong>. \u00a0Inside this loop you\u2019ll add two actions to get more details about the user:<\/p>\n

    \n
  1. Get user profile (V2)<\/li>\n
  2. Get manager (V2)<\/li>\n<\/ol>\n

    For both of these steps select the User Principal Name <\/strong>from the List group members action.<\/p>\n

    \"\"<\/p>\n

    The last action inside this second Apply to each loop is to Append to string variable<\/strong> again. This time, you\u2019ll add the contents of each table row you want inside the email. You can include any fields from the user profile, such as a link to their My Site, About Me, or their Hire Date.<\/p>\n

    \"\"<\/p>\n

    Working with lists from Get user profile<\/h2>\n

    Some of the properties output by Get user profile are lists \u2013 for example a list of interests, schools or skills. You can use the Join<\/strong> action to turn this list into a single string that you can use in the email. You can also use the join()<\/strong> expression to do it inline without having to create a different step. For example, I wanted a list of interests and a list of skills and interests, I\u2019ll show how to do that in an expression.<\/p>\n

      \n
    1. Select Add Dynamic content and select the Expression<\/strong> tab<\/li>\n
    2. Type join()<\/strong> \u2013 you\u2019ll see Intellisense for autocomplete
      \n\"\"<\/li>\n
    3. Switch back to the Dynamic content<\/strong> tab and find the outputs from Get user profile<\/li>\n
    4. Select the Interests<\/strong> output (or any of the other lists) \u2013 this should add the interests array into the join() expression
      \n\"\"<\/li>\n
    5. Finally, for the second parameter of join you need to add a delimiter \u2013 something simple like a comma and space works, so you can enter ‘, ‘ \u2013 be sure to include the single quotes
      \n\"\"<\/li>\n
    6. Select OK<\/strong> \u2013 you should see the expression token in your action<\/li>\n<\/ol>\n

      Wrapping it up<\/h2>\n

      You\u2019ll need to add one last action into the original Apply to each. Because the first Append to string variable created an HTML table, you\u2019ll also need to close out that HTML table with another Append to string<\/strong> action.<\/p>\n

      \"\"<\/p>\n

      Now you\u2019re ready to send the email. You should add that action at the very bottom of the flow (if you added it in the Apply to each you\u2019ll get more than one email). In the Send an email notification<\/strong> action you can fill out the To<\/strong> and Subject<\/strong> fields with whatever you\u2019d like. In the Email Body<\/strong>, all you need to do is use the Message <\/strong>\u00a0variable \u2013 it already has all of the groups and tables of their members, so you don\u2019t need to add anything else to the Body.<\/p>\n

      \"\"<\/p>\n

      Finally, if you want to run this flow from your phone or your desktop, just enter the name of an Office 365 group you own, and you\u2019ll immediately get a list of all of the members of that group \u2013 with helpful details about those members!<\/p>\n

      \"\"<\/p>\n","protected":false},"excerpt":{"rendered":"

      In this Flow of the Week, learn about how to work with Office 365 Groups and Office 365 Users. This flow will get all of the members of an Office 365 Group you own and send you an email report with those members (with details about each member). It will demonstrate a few advanced concepts like appending to variables , building an HTML email and using nested Apply to each.<\/p>\n","protected":false},"author":347,"featured_media":0,"comment_status":"open","ping_status":"open","template":"","power-automate-category":[2590],"power-automate-tag":[],"coauthors":[2913],"class_list":["post-110927","power-automate","type-power-automate","status-publish","hentry","power-automate-category-flow-of-the-week"],"yoast_head":"\nAdvanced | Flow of the Week: Get an email with the members of your Office 365 groups - Microsoft Power Platform Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Advanced | Flow of the Week: Get an email with the members of your Office 365 groups - Microsoft Power Platform Blog\" \/>\n<meta property=\"og:description\" content=\"In this Flow of the Week, learn about how to work with Office 365 Groups and Office 365 Users. This flow will get all of the members of an Office 365 Group you own and send you an email report with those members (with details about each member). It will demonstrate a few advanced concepts like appending to variables , building an HTML email and using nested Apply to each.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/\" \/>\n<meta property=\"og:site_name\" content=\"Microsoft Power Platform Blog\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/fotw-members-office365-button.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 min read\" \/>\n\t<meta name=\"twitter:label2\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data2\" content=\"Stephen Siciliano\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/\",\"name\":\"Advanced | Flow of the Week: Get an email with the members of your Office 365 groups - Microsoft Power Platform Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/fotw-members-office365-button.png\",\"datePublished\":\"2018-03-22T11:32:39+00:00\",\"dateModified\":\"2018-03-22T11:32:39+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/#primaryimage\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/fotw-members-office365-button.webp\",\"contentUrl\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/fotw-members-office365-button.webp\",\"width\":1219,\"height\":380,\"caption\":\"graphical user interface, application\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Power Automate\",\"item\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Advanced | Flow of the Week: Get an email with the members of your Office 365 groups\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/\",\"name\":\"Microsoft Power Platform Blog\",\"description\":\"Innovate with Business Apps\",\"publisher\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization\",\"name\":\"Microsoft Power Platform Blog\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png\",\"contentUrl\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png\",\"width\":194,\"height\":145,\"caption\":\"Microsoft Power Platform Blog\"},\"image\":{\"@id\":\"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Advanced | Flow of the Week: Get an email with the members of your Office 365 groups - Microsoft Power Platform Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/","og_locale":"en_US","og_type":"article","og_title":"Advanced | Flow of the Week: Get an email with the members of your Office 365 groups - Microsoft Power Platform Blog","og_description":"In this Flow of the Week, learn about how to work with Office 365 Groups and Office 365 Users. This flow will get all of the members of an Office 365 Group you own and send you an email report with those members (with details about each member). It will demonstrate a few advanced concepts like appending to variables , building an HTML email and using nested Apply to each.","og_url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/","og_site_name":"Microsoft Power Platform Blog","og_image":[{"url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/fotw-members-office365-button.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 min read","Written by":"Stephen Siciliano"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/","name":"Advanced | Flow of the Week: Get an email with the members of your Office 365 groups - Microsoft Power Platform Blog","isPartOf":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/#primaryimage"},"image":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/#primaryimage"},"thumbnailUrl":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/fotw-members-office365-button.png","datePublished":"2018-03-22T11:32:39+00:00","dateModified":"2018-03-22T11:32:39+00:00","breadcrumb":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/#primaryimage","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/fotw-members-office365-button.webp","contentUrl":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2024\/06\/fotw-members-office365-button.webp","width":1219,"height":380,"caption":"graphical user interface, application"},{"@type":"BreadcrumbList","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/fotw-members-your-office365-groups\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/"},{"@type":"ListItem","position":2,"name":"Power Automate","item":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/"},{"@type":"ListItem","position":3,"name":"Advanced | Flow of the Week: Get an email with the members of your Office 365 groups"}]},{"@type":"WebSite","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#website","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/","name":"Microsoft Power Platform Blog","description":"Innovate with Business Apps","publisher":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#organization","name":"Microsoft Power Platform Blog","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png","contentUrl":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-content\/uploads\/2020\/03\/Microsoft-Logo-e1685482038800.png","width":194,"height":145,"caption":"Microsoft Power Platform Blog"},"image":{"@id":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/#\/schema\/logo\/image\/"}}]}},"distributor_meta":false,"distributor_terms":false,"distributor_media":false,"distributor_original_site_name":"Microsoft Power Platform Blog","distributor_original_site_url":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog","push-errors":false,"_links":{"self":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-automate\/110927"}],"collection":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-automate"}],"about":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/types\/power-automate"}],"author":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/users\/347"}],"replies":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/comments?post=110927"}],"version-history":[{"count":0,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-automate\/110927\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/media?parent=110927"}],"wp:term":[{"taxonomy":"power-automate-category","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-automate-category?post=110927"},{"taxonomy":"power-automate-tag","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/power-automate-tag?post=110927"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/wp-json\/wp\/v2\/coauthors?post=110927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}