Thank you for visiting my site!

Home / PowerApps - Forms / Check if user is part of a SharePoint group – PowerApps App calls a Flow

Check if user is part of a SharePoint group – PowerApps App calls a Flow

Create a flow  that takes variables from PowerApps,
check is user is in a group,
and returns a variable with the result.

1. create an Instant cloud flow that can be started from Power with a button.

 

2. create the in variable from PowerApps
Rename it as the variable Name

For Value ask it from PowerApp

3. Send an HTTP request to SharePoint,
_api/web/sitegroups/getByName(‘use inGroupnameValue’)/Users?$filter=Email eq ‘use inGroupName_Value’

[code]_api/web/sitegroups/getByName(‘@{triggerBody()[‘inGroupName_Value’]}’)/Users?$filter=Email eq ‘@{triggerBody()[‘inUserEmail_Value’]}'[/code]


(or if you use Get my profile )

test the output.

[code] body(‘HTTPrequest’)[‘d’][‘results’][/code]

 

4. To test it out.

Create canvasApp with a button on it. add the connection to the flow created above.

On Button select Run the flow, and pass the variables.

 

[code] ‘flow_name’.Run(
"groupName",
"email@email.com"
)
[/code]

5. check the array value returned from HTTP is greater than 0

length(outputs(‘HTTPrequest’)?[‘body’][‘d’][‘results’]),
and set a variable to true or false.
6. Send a variable back to powerApp.

In PowerApp:

add the script on button

 

[code]UpdateContext(
{
result: ‘Flowname’.Run(
txtUserGroup.Text,
txtUserEmail.Text
)
}
);

Set( isAdmin, If(result.outisuser = "True", true, false)) [/code]

 

ADD YOUR COMMENT