Part 2: PowerApps Theme Component & AAD Security Group

Part 2: PowerApps Theme Component & AAD Security Group

Hi everybody Keith Craigo from WebDev By
The Bay! Last Saturday I created a new Theme Component, I’m using the new
experimental feature components in Microsoft PowerApps and this week I
added some more functionality to it I added a button to allow the user to save
their preferences to their device I also added another button so that if
the user is in an Azure Active Directory Security Group they’ll be able to save
their preferences to SharePoint if they’re not in the security group then
they won’t even see the button and I want to show you how to do that so let’s
get started, that was kinda of cheesy wasn’t it. You see here on my screen is my
developer tenant for Now it might be set up different in your
situation, your IT department may be the only ones who can create a security
group. What you see here are my security groups the one that I will show in the
demo will be BrandingSecurityGroup but I’m gonna walk you through how to set
that up. Let’s create a new group, you can choose Security or Office 365
I chose Security and I will just give this a random name and a random group now
I’m not going to create it I’m going to use the other one that I showed you
previously but in my case I can only do the assigned membership meaning that I
have to manually enter the information. Normally with a security group you would
set up a bunch of criteria to automatically create or automatically
add people to the membership based on their location, their country,
their job function, their title, their department, what have you but in my
developer tenant I only have a sign so I have to make I have to create all the
information myself. So let’s get out of that I will go over here to branding
security group and you can see that I am the only person in this group right now. Now you will need to go to properties,
you will need this object ID and I’ll show you why a little bit later.
Stay tuned for the next clip. Hi, so now we have a security group created
and in Azure Active Directory, we’ve added a user and now I’m back in PowerApps and before I get into this why don’t I show you the demo coming from my
iPad, let’s cue that up right now. So I’m gonna start PowerApps here I have my
iPad projecting up onto my screen here and I’m using QuickTime Player to record
on my screen so let’s launch PowerApps let’s give it a second or two and let’s launch the component library
here, not sure why that green bar stays on there, you have to touch it to turn it
off okay! I want to change a couple of colors the headers not connected to the
save to device, this blue bar up here at the top the header component is, that
background color is coming from SharePoint. Now you see that I have the Save
to SharePoint button that’s because I’m in the security group and I’ll show you
how to test that here. But first I’m going to save the blue, I’m going to, I’m
gonna change that – lets go cyan, cian how do you pronounce. And I will
save these settings to SharePoint and there’s my header component that’s
changed. Now I’m gonna show you the, I’m gonna go into offline mode and in offline mode I don’t need to
check to see if the user has access to SharePoint because if they’re offline
they can’t even get to SharePoint Online so that’s one thing you don’t have to
worry about. So let’s go into airplane mode and then let’s go back to PowerApps and launch the application one more time you’ll see the save to SharePoint is not
even visible, it’s not there anymore, so let’s go let’s turn this back on, just
take it take us out of airplane mode and we will go back in here, we will need to
uh! It’s automatically going out and there we go
okay why didn’t my, let’s refresh one more time and launch the app once more
get rid of that blue, green bar there and we should see the save to SharePoint
button, so we’re back in PowerApps and I am in the main screen of the application
and I’m going to the App OnStart property and what I do first, I load the
SavedTheme if there’s anything thing in on the device I load that first then I
determine if we are online or offline by using the Connection dot Connected
function and then I set an online variable to either true or false based
on that and here is where we need that security group objectID and I’m
creating a collection and I’m putting in that collection the return value of the
office365groups connector, you’ll need to add that connector to your PowerApp
the let’s bring that over you’ll need to add this office365groups connector ok,
Little diversion there sorry about that. Let’s go back to our OnStart property
we’re loading our branding security group collection and this and the list
group members function of the office365groups we pass our objectID our
security group objectID from Active Directory. Ok and then I need to do a
comparison of the current user to find out if they’re in this collection. Ok so
I am using the, for this one I’m using the office365users connector and I’m
specifically targeting the MyProfile function and the DisplayName of the my
profile function and I then use that to compare to see if it that name is in my
branding security group collection if it is I set SharePointAccess to true and I
set or if it’s not I set it to false. Now I need both the SharePointAccess
variable and the Online variable to set the visibility of this button and the
label. If both are true then we have access to SharePoint and the person has
the permission to access SharePoint if we, if both, if either one or false or
both are false then there’s no access and these will
not be shown at all. I hope you enjoyed this video if you did if you want to see
more videos please subscribe, hit the notification bell down below
once I get confirmation that my blog series on the PowerApps community blog
has been posted to public side, I’ll let you know I’ll put that link into the
show notes as well. I’ll post the URL to my other video down below.
So thank you for your time and I’ll see you next time
have a great day

Daniel Ostrander

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *