While working on the Canvas app sometime we want to get user details like name, email or other details. We can use this details depending on the requirement. Today we are going to discuss how we can fetch user details using 3 ways.
This article assume you basic knowledge of Canvas app, if you are new to Canvas app, you can refer this KB to get started with Canvas Apps
While working with Canvas app we can get user information from different sources like using default user method, office 365 or using other database which have user table. Today we are going to discuss how we can fetch user details from User method, office 365 and Dynamics 365, so let’s see how we can get these details.
1. Using User method
In Canvas apps we can use User() method to get following three details
Full Name : User().FullName
Email : User().Email
Image : User().Image
2. Using Office365 Connector
Now, If we want to fetch some other details we can also use Office365Users connector. We can fetch the details based on the current user email address like following
You can get information which is filled in the Azure portal, in below screenshot I am fetching these information from the office365.
3. Using CDS/Dynamics 365 CE User Entity
Now it we want to get these details from Dynamics 365 user entity. In order to get details from user entity, first we need to add connection to user entity. This will provide access to all the users but we want to see details for the current user so again we can filter it based on the current user email.
Let’s say we have following custom field called user type in system user entity and we want to show this field value in our canvas app.
Let’s first create a variable and set it using following formula
I am using above formula on Visible of the screen and then we can use following formula in Text of the label control like following
Now if I will run my app I will see following details:
Hope it will help someone!
Keep learning, Keep sharing !!