Get email of all members of SharePoint Group from Nintex Workflow Cloud workflow

  • 23 October 2020
  • 10 replies
  • 321 views

I need to get email of each member of SharePoint group from NWC so I could email them. Noticed that there are out of the box actions available to add/remove users from SharePoint group though. Please Help. Thanks
 

9313i07737D80D429FD26.png

 


10 replies

Userlevel 5
Badge +19

@Saran-Talan are you actually using a SharePoint permission group, or are you actually using a Microsoft 365 group? There is a way to get members of a Microsoft 365 (or Teams) groups, however getting members from a SharePoint permissions group is a little more challenging.

Hi @butlerj, Thanks for your reply, I'm using SharePoint permission group. When you saying challenging, does it means that there is no out of the box action/solution to do this please? if so, what would be the custom solution to achieve the same please.

Userlevel 5
Badge +19

@Saran-Talan Correct there is no "out of the box" action that will do this for you. However you should be able to make a web service call to the SiteGroups API to get members from a group:


 


_api/Web/SiteGroups/GetByName('SiteName Members')/users

You should also be able to query specific member properties using the query selector on that end point:


_api/Web/SiteGroups/GetByName('SiteName Members')/users?$select=Email

 


I haven't done this myself in NWC (just O365), but it should be doable. I'll see if I have time today to play around with the web service permissions to get this sorted.

Thanks @butlerj , I'll too try the same using the web service call and would let you know. 

Hi @butlerj, I have tried web service call action to get the members of a SharePoint group. However, I have been getting access denied error (screenshot attached). When hitting this request in browser, I am getting the response.


Could you find a way to achieve this?

Userlevel 5
Badge +19

@Akshat_Saxena are you able to test the request with a tool like Postman? The issue is most likely coming from the type of authentication you have in front of your SharePoint Online environment and you needing to get a Bearer token. If you're already signed into your site via the browser just using the URL will pass through your authentication to the GET request so it's not a perfect test of the end point. 

Thanks @butlerj. I am able get response for my request using Postman.


The problem I am facing now is that the access token expires after 24 hours.


I am wondering how to solve this issue and be able use 'Call a web service' action uninterruptedly in NWC to access SharePoint Online data. Any ideas/inputs regarding this.


 

Userlevel 5
Badge +19

@Akshat_Saxena typically this will involve a two step process. Before you make your call to create the group you will make a call to get the updated access token from Azure AD. This way each time the workflow runs you will always get an updated token. I'm actually a little surprised that your token lasts for 24 hours, as most would only last for a couple minutes for security purposes. 


 


Let me know if that makes sense.

Hi @Akshat_Saxena 


 


Did you ever work this one out? Were you able to use a web service and did you also have to get the token each time?


 


Jo

Badge +3

Once you get the response back from the HTTPS request, you can regex it into a collection.


Regex: (?<=Email":")(.*?)(?="})


 


Then loop through the collection and append the emails to a string variable. You can then use the string variable in the To section of the email.


 


It's not ideal, but it works. It would be great if there was a "Get SharePoint Group Members" action in NWC.

Reply