Adatis

Adatis BI Blogs

Getting user list from Office 365 in PowerApps

ContextIn the previous blog, we have gone through an overview of where PowerApps could be used and also some ideas on APIs that can be connected to it: https://bit.ly/2GPjghAIn this blog, we are going to go in some detail on the connection of PowerApps to Office 365 – and some examples of how this integration could be beneficial in application development through PowerApps.Office 365 and PowerAppsOne way though which PowerApps can be accessed, is through an Office 365 subscription. Once logged in you will see PowerApps available under one of the apps with this platform.Yet the relationship between Office 365 and PowerApps does not stop there. When building an application in PowerApps – which is going to be accessed in an Office 365 platform – there are various commands that may be used to add features to the developed application.For instance, presenting a list of users in a dropdown dynamically based on the Office 365 directory would be easy and adding “Office 365 Users” from within the data sources list will enable this.Once the connection has been added, two elements and a screen in PowerApps should be enough to provide the option to choose one profile from Office 365 directory.A ComboBox could be added from the Controls, and in this case we added a Label (which although it does not affect the functionality itself, gives a description). A ComboBox is like a normal Dropdown (which is classified as a separate control in PowerApps) but which amongst other slight differences, allow the selection of more than one item from the item list of the dropdown. It is worth saying that the allow multiple selection option can still be switched off. But I still prefer using this over a Dropdown because it allows the search option (which again can be enabled or disabled). This will apply an interactive filter to narrow down the list in the dropdown items.“User:” has been typed in the Text of Label1 and placed the ComboBox just beneath it on the screen. What the user inputs as a search text when using the application within the ComboBox can be called within the application using the SearchText function. In the Items of ComboBox1, which will determine what the user is to be presented with when the dropdown is clicked on, the connector is called through the Office365Users command. The SearchUser operation is then added, and as a searchTerm (which can be used as part of the SearchUser operation to filter the list), the ComboBox’s SearchText is to be used. The complete and proper syntax can be seen in the next screenshot.It is also important to specify which Office 365 fields are going to be used in the list and for the search – in this example it was the DisplayName.That is basically enough to present the PowerApps user a dropdown to filter and select a profile from. When running the application, the PowerApps user will start typing the display name that s/he intends to find, and the list is narrowed down. The user can then select the appropriate display name.What is also useful, is the ability to add other Labels, in order to get more information from the selected Office 365 profile. And this can be done with a simple syntax like the following:This way every time the selected profile is changed, the value of Label2, will change automatically depending on the selected value.Instead of MailNickname, there will be a whole list of attributes that can be extracted from Office 365 profile like City, Country, Id, Mail, contact numbers etc.Likewise, like the SearchUser() operation, there are many other operations that can be used in conjunction with Office365Users connector command. One other notable operation is Office365Users.UserProfileV2() which enables retrieval of data by passing the Profile Id or User Principal Name in order to get a whole list of information including skills, past projects, responsibilities, schools, interests and such fields that are available in Office 365 user profile:This is an example of the command that can be used for this:First(Office365Users.UserProfileV2(ProfileId.Text).skills).ValueProfileId in the above, is a label that is using a command to get the Id – which we will explain in the next section.User identificationHandling user logins and presenting different screens to different users within the same application is also easy.In order to, identify a user that has been logged in and display her/his details, another 3 elements within a screen should also be enough.One of the elements could be an image, added through the Media tab. And the User() function could be used to get back the image of the user (as updated in her/his profile).Two Labels can then be added and placed under the image, one displaying the name and the other the email with this syntax for each label (in Text property):Once the PowerApps user logs in, the details will show up on this screen. And similarly, the email could be obtained and used to filter out/ give access to certain controls or screens within the application.It is also worth noting that other functions like Office365Users.MyProfileV2() can be used to get a whole list of other details for the logged user – if the user has logged in through the Office 365 account.Getting back to the ProfileId label mentioned in the end of the previous section, the following command is being used to get the Id:Office365Users.MyProfileV2().idIt is important to keep in mind that even if there are various ways of retrieving such information, ensuring the use of a command that guarantees the retrieval of a record using a unique key is imperative. For instance, this command also returns an Id:First(Office365Users.SearchUser({searchTerm:User().FullName})).IdHowever, there can be more than one user in an active directory with the same full name. In this command we are getting the first profile and returning its Id – which is not always guaranteeing us the proper profile Id, especially if another user exists with the same name as the logged in user Wrap-upThis explains how easy it will be to develop and create such a capability in PowerApps solution. As pinpointed already, Office 365 and PowerApps offer other features that can be maximized through this connection and integration. And in a similar manner PowerApps can produce other positive results when connected and integrated with other relevant data sources and utilized as a user interface through application development!

Why PowerApps?

Having had the opportunity to work with the development and delivery of PowerApps applications on different projects, I feel that this technology provides a great modern solution to fill in business technology gaps, be a companion to software-as-a-service models and serve as an integrated frontend to various enterprise architectures.Uses of PowerAppsThrough PowerApps application, a user or business could now be presented with a simple and user-friendly, user interface to input or maintain data in different modes and for various reasons. Such applications can be designed to be used on mobile, tablet or desktops.PowerApps is another tool in the powerful Microsoft Power Platform. Most of us already had the chance to experience the benefits of Power BI within the reporting, dashboard and data visualization spectrum. When building reports through Power BI, it is normally essential to use Power Query to cleanse, standardize and prepare the data to a reportable state prior to modelling it and consequently start the development of the report. The effort required in this stage varies depending on the state and consistency of the dataset or database that is to be used to build the reports. And another benefit of PowerApps could be highly experienced at this stage.PowerApps could help in ensuring that data is kept in a consistent, organized and meaningful way, as opposed to leaving data entry validation at the stake of the user and applying endless data cleansing and preparation phases after its commitment. This will hence be also beneficial to any other data architecture like Data Warehouses. To highlight another benefit of PowerApps, building an application with this technology takes much less time then if coding such an application through managed coding languages. Likewise, I would say it also replaces the need to develop through VBA in Excel – by presenting a more scalable, modern and intuitive alternative.In this blog I am going to particularly focus on connections to data sources within PowerApps from a general perspective.Data sources in PowerAppsPowerApps allows the connection to multiple data sources and APIs. It can hence serve as a common handler of the data in different systems being used simultaneously within an organization.In order to include a data source in your application, the following few clicks are needed:1) Just go to View on the top ribbon2) Then click Data sources3) A column will show on the right, where the New Connection button can be used to add the required data source.4) And voila! There’s a whole list of connections to choose from, which range from other Microsoft products like Azure and Dynamics 365 to others like Google Calendar; social media favourites like Twitter, Instagram and Facebook; Marketing automation platforms like MailChimp; CRMs like Salesforce; Zendesk and so on.Once the login details for the connection are added, that data source could be used in the PowerApp solution in many ways as a data source, data processor or as a data destination.It is worth keeping in mind that some API connectors might only be available in Premium (which thus relies on the price tier/ under the plan that you are on). Such connectors are clearly identifiable with a gem icon beside them in the list. Some other connectors have a bulb icon beside them. This just shows that the feature is in experimental or preview. This serves as a warning to the developers when designing and developing their solutions, that such connectors are still subject to change and to be cautious when basing their system on them.Some connectors might also require some other details during development to activate their usage within the application, ranging from login details to Azure Keys etc. Yet once the application is published these connectors are treated as part of the application and any user granted access to the application will inherit the right to use these connectors as part of the application itself (without the need for her/him to have a relevant account for each and every connector). Upon loading the application the first time, the users will be prompted by a one-time message to have access to the connectors within:Once “Allow” is clicked, the users will be able to use as part of the application itself (with no other access outside the application being affected).Azure services with PowerAppsWhen acting as a frontend to Azure services, PowerApps can provide a cloud-hosted scalable solution facilitating the operation which might have otherwise required technical expertise.Just an example of this, Cognitive Services within Azure offers different AI solution that can be put in practice on a business level. Face API is one of these services, that can be used as a face verification and detection whilst integrating emotion recognition. Thus, by adding Face API as a data source in PowerApps (along with some other technologies like Microsoft Flow) one can easily provide a front end to take a person’s face image, have buttons included that trigger the analysis of those images through Face API and Microsoft Flow. Additionally, the results can be retained immediately and displayed in the same PowerApps solution. Azure Storage could also be added as part of the flow processes in order to retain a copy of the analyzed pictures – if required.This applies for the utilization of other Azure service in conjunction with PowerApps.The fact that PowerApps allows ease of input through Camera, Barcode Scanner and Microphone, it makes this technology versatile in data inputting methods and user interface adaptations. It hence also allows the opportunity to utilize the wide breadth of Azure Services that correspond with these data input methods.To sum up, this gives some ideas of PowerApps usage and an example of some applications that can be developed through PowerApps. It is also worth noting that PowerApps allows also the connection to custom APIs that have been produced through tailor-made development. Hence in these cases it will also serve as a potential front-end especially in cases where expertise in technical languages used in UI is lacking.