I have a workflow that was in O365 that I am trying to upgrade to NWC. Everything went pretty well except two fields/variables. In SharePoint I have a list that has two fields that are people fields. They are single select that pick from two different SharePoint groups. After the upgrade, I can’t select that field because it is greyed out. I have a third field in SharePoint that is multiselect people field that works just fine. Can someone point me in the direction of how to get the email address of the people picker fields?
Best answer by Prineel_V3View original
Just to confirm, you have 2 SharePoint columns that are set as “people and groups”, and you want to retrieve groups (emails of the people in those groups) from those columns?
I have two SharePoint columns that are “person or group” that allow one person to be entered. The column is set to only allow one selection from a certain SharePoint group. I need to retrieve the email address from the person selected so that I can send them an email.
Ok cool, does NAC (previously known as NWC) return the ID of the SharePoint columns (either in your start event or your if you query the list), should look something like this (Column name (ID)):
No, I get the column name followed by (Username), but it is greyed out. I don’t get the option for email or ID like I do for ones that are working.
Interesting, is it possible to send a screenshot of how your column is setup, does it have a custom column format?
Sure. No custom form
And this is what NAC shows.
That's extremely weird that you don't get the ID value back.
Possible Fix 1:
Try changing the column to “People only” in SharePoint, go to NAC, press ctrl+F5 on the workflow canvas (This will refresh your page, so save any changes you need to)
Go back to your variables in NAC, you should see everything you need (including the email, if not let me know if you at least get the ID).
Possible Fix 2:
Re-connect to your connections (please make sure the connections are created/signed in using a SharePoint admin account/service account) and re-configure your start event action.
If you have multiple selections enabled, that could also complicate things in NAC, I don't think that's what is causing the problem though.
Changing to People Only gives me the ID. But still no email.
Cool. Its progress.
We can use that ID (Its the user’s ID) to query a webservice and then query json to get the user’s email and name:
1. Use a call a SP web service action and in the URL section, put your site URL followed by “_api/web/getuserbyid(INSERT COLUMN ID HERE)” and output it in an object:
2. Use a Query JSON action and use the response content variable from your previous action’s object with the following expression “$['d']['Email']”. Output it in a text variable.
You can do the exact same for the name, just use this expression “$['d']['Title']”
you can also test if it returns the correct user by putting your site url with the _api/web/getuserbyid(userID) link directly in a browser tab.
If this doesn't work, try using the following api URL instead
Hope this helps
That worked perfectly. Thank you so much!