Web Roles and Enhanced Data Model
Help UKRAINE ! Your action matters! Donate to support Ukrainian Army! Donate to charity funds! Organize/join street protests in your city to support Ukraine and condemn Russian aggression! Expose and report Russian disinformation! #StandWithUkraine
Web Roles are the core of the Power Pages security. They define who and how can access the data on our site. We are using them constantly. However, if you enabled the Enhanced Data Model you might notice that things are different: Related records missing associated Web Roles, and dynamically assigning web roles via adx relationship doesn’t work anymore. In this article, I will show you what is going on with Web Roles in the new data model and how you can resolve both of the mentioned issues.
How the Enhanced Data Model works
Enhanced Data Model doesn’t have separate tables for many things. Instead, it uses a table called Site Components that holds everything (from Web Role, and Site Settings to Web Files). Then Microsoft uses plugins and some magic to present those records as separate tables via Virtual Tables. So the Web Role that you see for the Enhanced Data Model (table name mspp_webrole) is actually just an abstraction on top of the Site Component table. Microsoft just presents it to use as separate tables in a familiar interface.
How to find currently assigned roles
Previously, when you tried to find Web Roles assigned to a contact, you would go to the Related tab on the Portal Contact form and select Web Roles. However, if you do it now, it will show you the old adx_webrole table. Unfortunately, you cannot show the virtual table in the Related section.
To view roles, currently assigned to a contact, open a contact using the Portal Contact (Enhanced Form) form, and navigate to the General tab > Web Roles section. There you will see a list of already assigned roles and can assign new ones as well.
How to dynamically assign roles
Previously, with the Standard Data Model, when you wanted to dynamically assign a web role, you would use, for example, Power Automate to associate the Contact table with the Web Role table via adx_webrole_contact relationship. But, with the Enhance Data Model, you need to use the Site Component table instead. On the Contact table, you have the Relationship called powerpagecomponent_mspp_webrole_contact which links the Contact and Site Component table. Use that relationship and the odata id of the web role (mspp_webrole one) to associate the table (you can get the Odata id if you get that web role via Get Row action or in the next format https://ORGNAME.crm.dynamics.com/api/data/v9.1/mspp_webroles(GUID).
How to dynamically remove roles
Similarly, to how we associated web roles we can dynamically remove them using Power Automate. This time, however, we need to get odataid of the Site Component behind the Web Role. To do so you can first query Web Role by name and then query Site Component by id or if you know that id query it directly. After getting odataid we need to perform an Unrelate action from the contact to the Site Component table via powerpagecomponent_mspp_webrole_contact relationship.
Conclusion
Enhanced Data Model is a big shift to make Power Pages more aligned with the usual ALM story for Power Platform, more performant and easier to update. And, although, from the surface, things might look the same, under the hood a lot has changed. This includes changes to the Web Roles and how we interact with them. In this article, you found how you can find current associated roles and how to dynamically assign new ones. Hope you find it useful.