cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MihirY
Level 8

Is it possible to switch the view as InfoPath, in powerapps?

In infopath we can switch the views based on user role. Consider an approval of infopath form. If user is authorized to view the form then we can show approval form or else we can show unauthorized view. Now i want to achieve similar kind of functionality with power apps. Is there any way to do such thing by applying any formula or rule etc? Of course it is not possible to do many customizations as infopath but want to try a small approval with power apps. 

9 REPLIES 9
BitLord69
Level 10

Re: Is it possible to switch the view as InfoPath, in powerapps?

Hi!

 

Great question, and I just had a play around to check it out, and it does seem to be possible!

 

I have a button in a gallery with lots of fields, one field is a user's email address. In the button's OnSelect I used the AzureAd-connector making two calls, to the GetMemberGroups- and GetGroup functions with the following code: 

 

 

UpdateContext({asIL:AzureAD.GetMemberGroups('Office365-användare'.UserProfile(BestEpost).Id;{securityEnabledOnly:true})});;
UpdateContext({asLL:Concat(asIL; AzureAD.GetGroup(Value).displayName; Char(13))})

 

 

The BestEpost is a field in the gallery (database) with an email-address. I do the process in two steps: first I collect all the group IDs into asIL (array of strings illegible list) and then I collect the legible group names into asLL in the second call. Of course, you might want to use User().Email instead of my database field (you could probably use 'Office365-användare'.MyProfile.Id instead). That way you check only your current user of the app.

 

Outside of the gallery I have a circle hard coded to be visible when the clicked user belongs to a certain group (SG-FM-itbest in this case):

 

 

("SG-FM-itbest" in asLL)

 

If the user is a member of the hard coded group the circle is visible and vice versa! This button could be used to show an admin panel, a certain gallery, other menus or whatever you see fit. It works really well, except for note II below.

 

Note I: The 'Office-365-användare' is the localized version of Office365User - no clue why MS thinks the name should be localized...

 

 

Note II: Quite often I get the error message: Rate limit is exceeded, but don't know why and waiting for a short bit seems to fix the problem.

 

If I were to make an app and check permissions only for the current user I'd put the calls to AzureAD into the main screen's OnVisible. If the app needed to check a user for say admin-privileges, I'd set a boolean variable using the in-operator, checking for membership in the correct group and lastly use that boolean value to set the visibility of objects. 

 

Get back to me if something is unclear or doesn't work.

MihirY
Level 8

Re: Is it possible to switch the view as InfoPath, in powerapps?

Thanks for your reply. as you said i can do on button select with Navigate function as well. But I want to check on screen load. I am trying like below

If(DataCard_Manager1.DataField=User().FullName,DisplayMode.Edit,DisplayMode.View

But it is not working. Formula is not showing any errors.  

BitLord69
Level 10

Re: Is it possible to switch the view as InfoPath, in powerapps?

Where did you put the code in your example? 

 

You probably need to check the .Value property of the DataCard_Manager1.DataField, so 

 

If(DataCard_Manager1.DataField.Value=User().FullName,DisplayMode.Edit,DisplayMode.View
MihirY
Level 8

Re: Is it possible to switch the view as InfoPath, in powerapps?

I have to check while screen is loading. If Manager name is equals to current user name then show it otherwise navigate to other screen where I am showing unauthorized messaage.

And also is there any possibility to check whether current user belongs to a SharePoint group or not?

BitLord69
Level 10

Re: Is it possible to switch the view as InfoPath, in powerapps?

Hi!

 

If I understand you correctly you just want to check for unauthorized use, and if so display a certain message? That is completely unnecessary since you only share the app with people with the right to use it. There is no way a person who are not allowed to to use that app can use it if you share it properly, i.e. not to everyone in your organisation.

 

I have no clue how to work with SharePoint, so I can't help you there.

MihirY
Level 8

Re: Is it possible to switch the view as InfoPath, in powerapps?

What you have understand is correct.In sharepoint there will be security groups. Requirement is need to check current user is there in any group or not.

but unfortunately currently there is no solution to check whether user is belongs to particular SharePoint group or not. Related post.

 

rorybi
Level 8

Re: Is it possible to switch the view as InfoPath, in powerapps?

Hi,

 

If you're going down a sharepoint route you can create roles/permissions in sharepoint to control what people can/can't see.

 

One of the settings that is available on a list is to make users only able to see their own items.

 

You can use active directory to house the users.

 

In this way you can use active directory to be the base point for 

  • Sharing the app
  • Assigning security levels that are associated with lists

Beyond this you can create interesting variations by using flow to perform more complex tasks such as sending conditional emails etc.

 

Cheer,

 

Rory

rorybi
Level 8

Re: Is it possible to switch the view as InfoPath, in powerapps?

Hi,

 

If you're going down a sharepoint route you can create roles/permissions in sharepoint to control what people can/can't see.

 

One of the settings that is available on a list is to make users only able to see their own items.

 

You can use active directory to house the users.

 

In this way you can use active directory to be the base point for 

  • Sharing the app
  • Assigning security levels that are associated with lists

Beyond this you can create interesting variations by using flow to perform more complex tasks such as sending conditional emails etc.

 

Cheers,

 

Rory

kbirstein1
Level: Powered On

Re: Is it possible to switch the view as InfoPath, in powerapps?

It's difficult to understand the solution here because it's in German.

 

Here's the solution in English.

 

This gets the Security Groups a user belongs to and returns their AAD Object IDs (true means get the security enabled groups) and puts them into the collection "colSecurityGroups":

 

UpdateContext({Secgroups:AzureAD.GetMemberGroups(User().Email,true)})

 

This takes the Object IDs and turns them into a string value separated by a comma:

 

UpdateContext({secdisplay:Concat(Secgroups,AzureAD.GetGroup(Value).displayName,",")})

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,923)