Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Getting Current User Details In Canvas Apps
WhatsApp
Mahender Pal
4y
13.3k
0
4
100
Article
Requirement
While working on the Canvas app sometimes we want to get user details like name, email or other details. We can use these details depending on the requirement. Today we are going to discuss how we can fetch user details in three different ways.
Details
This article assumes you have basic knowledge of the Canvas app, if you are new to it, you can refer to
this
KB to get started.
While working with Canvas app we can get user information from different sources, such as using default user method, Office 365 or using other databases which have user tables. 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.
Using User method
In Canvas apps we can use User() method to get the following three details:
Full Name : User().FullName
Email : User().Email
Image : User().Image
So if we can place an image control and labels we can use the above formula like below:
So if I check these details for my user, I am getting details like below:
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
Office365Users.UserProfileV2(User().Email).companyName
You can get information which is filled in the Azure portal, in the below screenshot I am fetching this information from Office365.
Using CDS/Dynamics 365 CE User Entity
Now it we want to get these details from Dynamics 365 user entity, first we need to add a 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 the following custom field called user type in the system and we want to show this field value in our canvas app.
Let’s first create a variable and set it using the following formula.
I am using the above formula which will get D365 CE user based on its domain name and then we can use the following formula in the text of the label control like the following:
Now if I run my app I will see the following details:
In the above image, the details are fetched using above 1.2 and 3 option.
Summary
We can use the above options to get different information about the current logged-in user. This is helpful when you want to show/hide controls based on the current user.
I hope it will help someone!
Keep learning, keep sharing!
Canvas apps Fetch current user details
Up Next
Ebook Download
View all
Printing in C# Made Easy
Read by 22.3k people
Download Now!
Learn
View all
HIMBAP
We are expert in Microsoft Power Platform.
Membership not found