What does “context” object hold in Power Apps custom component framework. Organization info, user info, web API methods and more!
After my detailed post on Power Apps Custom component framework, I have getting loads of queries and among them the common ones are
- How do we get organization details within my Power Apps custom control
- How to get context user information
- How to get record information on which the control is embedded
- How to query Web API from my control code.
The answer to all of these lies in the context object that gets passed to the init method of your control. Just like with Plugin context, the control context contains all information about the current environment in which it is executing.
So let’s explore what the context has in store for us. And what’s better way than the wonderful developer tools of Chrome browser. Below is a screenshot of the property bag that context contains.
The important ones I just highlighted. So let’s go a bit granular on the highlighted one.
1. page:
context.page can help you with useful values like the id of the current app which is loaded, the guid of the record and the logical name of the record on which the control is showing up.
And also our very own lovable method – getClientUrl().
2. orgSettings
I think the name justifies all. This gives us all the values related to the CRM organization. And this is the same one you get when you query for Organization Settings using Xrm.Utility.getGlobalContext()
3. userSettings
This will give you information about the logged in user security roles, language code, user id etc.
4. webAPI
Well this can be very important. Specially if you want to query CRM web api from your control. Here you get all the methods to communicate with CRM Web API.
Hope that gives you all the information to get started with your first custom component.
Hope this helps!
Debajit Dutta
(Dynamics MVP)
For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com
Our product offerings:
Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)
CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)
Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)
Multiselect picklist for Dynamics 365 (http://www.xrmforyou.com/multi-select-picklist.html)
This was originally posted here.

Like
Report
*This post is locked for comments