PCF in Dataverse for Microsoft Teams

PCF in Dataverse for Microsoft Teams

After creating my Microsoft OpenAI powered Intelligent Assistant canvas app was still one open question for me, “Can I install and uses my Intelligent Assistant also in Dataverse for Teams?” You might also have the question, “Why would you consider bringing your Intelligent Assistant into DataVerse for Teams?”

Well, integrating my Intelligent Assistant into DataVerse for Teams offers several advantages. One of them is that canvas apps empower users to create intuitive and tailored interfaces for data management, enhancing collaboration within Teams. Furthermore, the integration of Dataverse brings a powerful database and data modeling capabilities to Teams, allowing for seamless data organization and analysis. Additionally, the unique licensing model of DataVerse for Teams provides cost-effective access to the platform’s extensive features and functionality, making it an attractive option for organizations of all sizes.

First of all, let’s answer the technical question. Is it possible? To do that, we’ll take a closer look at my Intelligent Assistant solution and its dependencies.

In detail, I use my Visual Studio Code extension PowerApps Helper to visualize my current solution dependencies. Here you can see, that my canvas app depends not only on my custom connector for Azure OpenAI:

Furthermore, there are two additional dependencies. First of all, I have also added my PCF code component MarkDown Viewer from MarkDown Viewer solution. I described this in my last blog post.

In addition, I use often the template app and some controls from “Material Design Component Library for Power Apps”. This solution was created by our German Microsoft MVPs Luise Freese and  Robin Rosengrün.

The bottom line is that there are two additional dependencies that I need to resolve first. Importing the component library into Dataverse for Teams is not a challenge. I have already explained this in detail in “Create beautiful Canvas Apps in Dataverse for Teams“. But, what about the PCF control? Can I use PCF in Dataverse for Teams? Let’s see…

Note: It is important to be aware that neither Dataverse for Teams nor Microsoft supports the capabilities demonstrated in my example below. However, I decided to write about what I found out. I believe PCF in Dataverse for Teams add significant value to the platform and highlight potential opportunities for future development and integration.

Importing my PCF control in Dataverse for Teams

OK, let us start. As I told you, the solution import in Dataverse for Teams is not a problem. I can access my Dataverse for Teams environment with Power Automate. For that reason, I navigate to https://make.powerautomate.com, select my solutions and start the import with the downloaded my PCF component:

Download URL: https://github.com/megel/PCF-MarkDownViewer/releases

The result was as expected:

This surprises me in a positive way! I was able to install my solution. Furthermore, I see my PCF code component here in Dataverse for Teams:

Ok, I have a 2nd dependency. In detail, I repeat this exercise and import my 2nd solution, the Material Design Component Library. Again after some minutes, this message appears: "Solution "MaterialDesignComponentLibrary_1_0_0_8.zip" imported successfully with warnings". But where is my solution:

I have double checked this in my Solutions History. Yes, "MaterialDesignComponentLibrary_1_0_0_8.zip" was imported correctly but why it’s not shown?

The answer is simple. "MaterialDesignComponentLibrary_1_0_0_8.zip" is an unmanaged solution. It seams to me, that unmanaged solutions are gone after import in Dataverse for Teams. That’s a little bit strange. However, my components are there and I decide to continue.

Finally, I import my also my Intelligent Assistant solution. This works as expected, because my Intelligent Assistant is also a managed solution:

Perfect! Everything is correctly imported including my PCF. But are my canvas app and my PCF control working correctly?

Double Check PCF in Dataverse for Teams

Let’s do a quick double-check. For this, I start my canvas app:

But first of all, I have to setup a connection to my Azure OpenAI resource:

Info: Sometimes this dialog does not appear in Dataverse for Teams. However, for this reason I mostly use the web user interface.

My connection setup worked well and my app started. Wait!!! I can enter something in my chat, but nothing is displayed?!? Darn, where is my chat content? In other words, where is my PCF code component!!!

I found out, my component is not presented. This is because I did not enable the Power Apps component framework in my Dataverse for Teams.

Let’s go for it and enable PCF in Dataverse for Teams!

Enabling Power Apps component framework in Dataverse for Teams

Normally, I navigate to the Power Platform Admin Center in order to change my dataverse environment settings. Underneath category Product I find a link to my environment features:

Moreover, I can search for Power Apps component framework in my environment features. After enabling this I can use code componente (PCF controls) in my canvas apps:

So good so far. Doing this in Dataverse for Teams is impossible. This is because Microsoft have reduced the functionality for Dataverse for Teams to the end users. In other words, my Settings in this environment settings are extremely reduced. I see only this:

You see, I can access the Product Features of Dataverse for Teams, but the next screen is almost empty:

The is no option to enable the Power Apps Component Framework. What can I do? Are my settings available somewhere else?

Changing Hidden Settings in Dataverse for Teams

Yes, there is a way to modify the behavior and the settings of Dataverse for Teams. But, before I continue please read, because we are definitely leaving save and official supported path now:

WARNING: Please continue at your own risk. I’m sure, what I show you is not supported or intended by Microsoft.

Luise Frese told me once: When you find no way as a Citizen-Developer to achieve your goal, try to act as a Pro-Developer!

So let me say it another way: We should never forget, Dataverse for Teams is a real Dataverse. For that reason, we have access to the APIs. Furthermore, the Dataverse admin center user interface are also using these APIs to change the settings of a normal Dataverse. In other words, the UI changes a Dataverse entity.

I discovered, the Dataverse settings are stored within the entity organization. In fact, you only need the Organization ID, the host (environment URL) and a Bearer token for authorization. Here is a simple HTTP call to query all settings:

@host           = orgb0....api.crm.dynamics.com
@organizationId = f43dc749-...
@token          = ey...

### Get all options GET https://{{host}}/api/data/v9.2/organizations({{organizationId}})
Authorization: Bearer {{token}}

Furthermore, you can also modify these information by using the PATCH method. Here is an example:

@host           = orgb0....api.crm.dynamics.com
@organizationId = f43dc749-...
@token          = ey...

### Enable PCF option PATCH https://{{host}}/api/data/v9.2/organizations({{organizationId}})
Authorization: Bearer {{token}}
Content-Type: application/json 

{ 
    "iscustomcontrolsincanvasappsenabled": true 
}

After patching my Dataverse for Teams organization settings with this HTTP call my PCF control is no longer blocked. Wow, that was easy.

Let me double-check, yes the value was set correctly:

But again, my App did not present my PCF control. Hmm, this would by a bad ending for my blog post… Let my check, if I can use my PCF in a canvas app in Dataverse for Teams.

Now my curiosity is definitely piqued!

Using PCF in D4T

New try! I start by creating a new canvas app in Dataverse for Teams. My designer opens and I enter a new App name:

I add my code components by Get more components and selecting code. Afterwards, I select my MarkDown viewer PCF component and start the import.

The import of my PCF code component is finished. Now I see my PCF component underneath Code components in Dataverse for Teams:

I add my component to a screen. Alright! My component is rendered correctly and display the default MarkDown text:

Now I save and publish my canvas app:

Finally, I add my created canvas app to a new tab into my Teams channel:

… and surprise again, my new PCF in D4T canvas app as well as my PCF code component works in Dataverse for Teams as expected:

But what is wrong with my Intelligent Assistant app?

Publishing my Intelligent Assistant in Dataverse for Teams

To find this out, I must open my managed canvas app my Power Apps Designer. However, this looks like an endless loop in Microsoft Teams. Because, this dialog opens a couple times:

Well, there is a new version present. I try the new version. It’s loading again and again…

Than, another window opens. Yes, the well knows "This app may contains unsafe code" warning:

Wow, I continue and open my canvas app. I’m surprised again, my PCF code component is present and work correctly. My component is displaying the initial chat message:

Hmm – maybe I must publish my app again. Let me do this. I start publishing this version again:

Afterwards, I add my app to my channel in a new tab Intelligent Assistant:

Wait, it’s loading…

Oh no! Looks like this is not going to work…. But success and failure are part of the game.

One last try. I have an idea – I change something in my app to force the creation of an unmanaged layer. To do this, I simply change the label of my canvas app:

I save my canvas app again and start finally publishing my app to Dataverse for Teams. Once more I have to wait:

… oh yes … Success!!! Look at this:

Well, finally my Canvas application works as expected with my PCF code component in Dataverse for Teams.

Summary

First of all, Dataverse for Teams is a powerful collaboration tool that allows organizations to store, manage and share data in the Microsoft Teams environment. There are still some issues and lots of limitations that users and companies may encounter. On the other hand, Dataverse for Teams also offers many advantages. For example, Dataverse for Teams offers an interesting licensing model for basic functions. Another advantage is that you can reach your users with your apps where they collaborate and communicate.

However, there are some disadvantages as well. When you try to install and develop Canvas applications, you will encounter several challenges. Furthermore, I know in Dataverse for Teams exist many limitations and we can’t use certain features. But I see also the other side. I see, many of these problems can be solved with a little bit Pro-Developer magic. For example, I showed you how I enabled PCF code components in my Dataverse for Teams environment. Although I know this is not officially supported, can Iimagine from this example what potential lies in Dataverse for Teams with PCF enabled.

To conclude, while Dataverse for Teams offers various advantages such as a convenient collaboration environment and a flexible licensing model, there are limitations and challenges, particularly in relation to developing Canvas applications. One unresolved question remains: if PCF were enabled, would it be considered a premium feature in Dataverse for Teams?

Share
Comments are closed.