Skip to content
Why Power Apps Portals needs an API episode artwork

Jul 21, 2020 22 min

Why Power Apps Portals needs an API

from CRM Audio Hosted by crm.audio

New in preview, Microsoft has released a CRUD API for Power Apps Portals. Why do we need this when Common Data Service already has a web API? Hint: It's not for integration, it's for user experience. See the official documentation here: https://docs.microsoft.com/en-us/powe...

Episode details come from the podcast's RSS feed.

Embed this episode

Ready to play

Why Power Apps Portals needs an API

0:00 22:39
of matches

Transcript Auto-generated, may contain errors

Welcome to CRM Audio, the Microsoft Business Applications and Power Platform Podcast. I'm Joel Lindstrom here today with George Dubinsky. George, how are you doing today? I'm very good. I'm just dancing to your wonderful music. Who wrote that? It was some guy on Fiverr that I paid to write a song about Ben Ballmer.

Oh, that's right. That's right. So last week we had a podcast where Sean Tabor and I talked about the Wave 2 2020 release plan. And I think it was a pretty good episode. You should go listen if you didn't. But the one topic that we really were not qualified to talk about was the portals web API. And I believe my quote was, why do we need an API for portals when we have a SDK for CDS already and a web API? So you're here to tell us why we need a portal API.

Are you talking to me? Yes. Oh, I'm sorry. Any other hosts sitting around here? No, no, I'm just looking around. I'm just kind of, anyone, anyone? Now, look, the interesting part is that Portal Web API, it scheduled for public preview, like you see it in December, right? Right. But it's winter in Australia, but it's definitely not December, but you already have the Portal Web API preview. So we can include a URL inside the show notes, but basically it's available now.

And its ability to call effectively CDS API. Well, kind of CDS API. I'll talk in a second. So its ability to call directly into CDS using API, which kind of resembles web API, the CDS web API, directly from the portal. And when I say directly from the portal, I mean from the JavaScript, from the pages. So you have endpoints that you can call. Well, not only from JavaScript. You can call it from anywhere. I assume you can call it from third-party applications. I agree.

It doesn't need to be the same web application. Maybe it does need to be. So anyway, so the idea behind it, ability to call into this web API, is to give developers ability to perform crowd operations. Currently, you don't have, within the Power Apps portal framework, you don't have ability to perform any operations except retrieve or retrieve multiple, which is part of the liquid language. So when you're creating a page or a page template, you can kind of...

fine-tune your retrieve operations. You can run fetch XML. You can extract data. You can do certain things. You can lay it out. So you can feed data back to the browser, right? If you want to update, your only option to update is the form. So you're kind of limited to what you can do when you want to create, update, and delete is a special one, special operation. You can delete it. You can add a button that deletes the record, but you kind of, you don't control what's going on. You don't control...

how it's happening, you just control where to place the button, so to speak. And for create and update, you only control which form you can display, but you don't have any ability to create thin line operations or do some batches. I'll give you the most common use of that, most popular. And I should really finish the part that I have on editable grids, right? So inside the portal, one of the common requests is to create an editable grid, which would be equivalent of the editable grid that you have inside CDS or a model-driven app or Dynamics 365. Now,

So the typical example would be, say, you are purchasing products. So you have something like, you build an invoice, for example, right? So you have invoice lines. So you want to be able to build those lines and then submit those and the invoice would go through. So you want kind of editable grid experience, but you can't have it in portals because you need to be able to talk to backend to CDS as you build in that grid. So you need to be able to build those lines in. And I'm saying like, before you create invoice.

If you have an invoice and you have this disconnected experience, you know the experience, the old one without editable grids. I have an invoice. I want to add a line. I go into the form to add the line. I added the line. I'm back into invoice. I add another line. And it's just terrible, terrible experience for users, right? So what you want is kind of add the line, add the line, add the line, all in line. And it's kind of the same. So I want to be able to create invoice details without going into the form on the fly. That's what those operations allow you to do.

I was a long-winded explanation. It was horrible. Yeah, that makes sense. And in my defense last week, this documentation wasn't published when we did our last episode. But the documentation, which I put a link in the show notes for, is it clarifies that Portals Web API operations are limited to entities related to data. They're not for integration purposes. So they're designed for creating rich user experiences in Portal pages. So let me ask you this question.

Security-wise, is this open up any new threats? For example, can some of the external API or is it limited just to be used with controls that you develop for the portal? Okay. So I'm just reading about that. So details what's been published. One of the things sounds like you can forget about what I said, you can access it from elsewhere. No, you cannot because all web API calls must include cross-site forgery.

token, CSRF token, which is basically combat state cross-site forgery. So you can't call this web API, portal web API, from outside. You need to be talking to the portals. So you can call it from the same page that you're displaying. You can't leave the site effectively. Now, when you call portal web API, which looks kind of similar, they try to do it very, very similar to create a similar structure to a web API, CDS web API. So developers kind of feel comfortable using that API. So the portals web API talks to the entities.

in CDS, but it applies entity permissions. So, for example, if you don't give anonymous access to any of the entities, it's a reg scenario, but let's say you say I'm locking down portal completely, so entity permissions, there is no public access to any of the entities, full stop, right? Then no matter how hard you try and bash this web API, nothing will get through. because the entity permissions will just block it completely. So you won't be able to access. If you didn't configure anonymous users to have, for example, any create permissions anywhere, then you won't be able to create anything. Then, for example, you can start opening up bit by bit. You have a form on the contact us page and you want kind of a pop-up experience on the fly. So you want to call this web API, a portal web API on the fly from JavaScript. So what you would do, you add entity permission for anonymous users to be able to create leads.

for example, right? So that gives you ability to call web API on leads entity, create, send, create message. And again, you control the fields that go through. So it's kind of, it's a very tight control. Obviously, it's not a, it's kind of, it doesn't have mechanisms to, against things like denial of service attack. That would happen much earlier than that. So Microsoft, because it's an Azure web app, it would have a firewall.

and mechanism to protect against denial of service. Let's say repeated access from the same heavy hammering from the same IP address or something like that. Some indicators of heavy attack. So that would have some built-in protection against that. as far as the data is concerned you go through multiple roles so you go you go through the portal web api so there's a limited number of operations you can do then you define which entities you have access to entity permissions i applied and checked against the web roles that you have your users have i gave example to an anonymous user but if you're authenticated user you might have one of the multiple web roles then you can allow people to do some more some additional operations with the web api so there's a heavy dependencies on what's going on So the risk is, to me, it's not much greater than anywhere else. It sounds like you limited it to only being available once you're inside. And once you're inside, there's a lot more things you could do anyway. True, true. And keep in mind that none other than marketing portals, right, that are not quite the same Power Apps portals as the rest of them, the marketing portal has been using this approach for months now, right?

So they're using the same approach. There's a kind of API layer and they call this API that in turn calls CDS API. So it's kind of proxy. It's proxy in the API. That's what it is, right? So one of the big portal announcements is PCF controls and portals. Is this related to that? I mean, is the API, is the portal API necessary to support PCF controls? Yeah, definitely, definitely. So one of the things that PCF controls do, they kind of...

When you create PCF controls, you build in HTML on the fly. You effectively build and think like what you had with web resources. You have web resources that talk to something and so on. With PCF control, you effectively get very fine control over the code that gets generated and HTML that gets generated. You're kind of sitting very, very close to the surface and you generate layout and you generate code. Now, these code or rather PCF controls that have these layers.

They have these multiple layers that allow you to talk to CDS, right? So PCF controls, by definition, they can be bound, they can be unbound, but they have a number of operations to be able to talk to CDS. So without that, PCF control is as good as a brick. It probably will still render. It just won't be able to talk to the data.

Right. So it won't be able to get any data. So if you have, let's say, a smart. The only empty editable grid. Yeah, that's right. So like if you have a drop down control, let's say a super smart drop down control that, you know, creates a wonderful experience when dependable, you know, dependable drop downs. So it will display drop down control most likely, but absolutely nothing bound. So whatever control, you know, gets by default, that would be it. So no access to the data.

for PCF and no updates either. So if when PCF controls is bound, binds to the data, it can update it as well. So it's kind of can send data back so that you lose completely communication between control and the data. So rendering is fine, but what you're rendering is nothing. So yeah, definitely you need this layer for PCF controls to work. What would be interesting to see, because API, as I said, API is kind of similar, but not quite the CDS web API. So what would be interesting to see how PCF controls are going to consume that kind of proxy layer.

Are they going to have HTML? So what's going to happen? I don't know. It's yet to come. But definitely it's there. People started exploring it. Anyone you know tried it already? Because I've seen like one or two articles. People have tried it. One post in the forums by Andrew Butchenko that he's something about a PCF-controlled portal. So I don't know if he's actually done it or was playing with it or what. But the interesting thing I'm seeing, I've actually seen over the last week, two or three people asking questions in the Power Users forums who are using...

PowerApps portals, but aren't using model or canvas-driven apps, model-driven or canvas apps. So they're coming at this, like, how do I integrate with the portal? Or how do I trigger a flow when a change made on the portal? And I've answered that, well, you need to go into common data service, and it's the same as with the model-driven app. So I think this will have the effect of making the PowerApps portals a much more interesting platform to a lot of people. It's kind of interesting that you picked it up. There are a couple extra things I wanted to mention. One is, when you read what's available on the portals, is create, update, delete. So we have cut, not crud.

And there is associate and disassociate. And that was asked, like, why did that happen? And that's pretty much a team prioritizing what to expose, because we already have Retrieve. Remember I mentioned earlier that liquid language gives us the ability to Retrieve. So it's never been a challenge. So what are the options we have now for integrating with other things besides CDS? Is it just use traditional integration methods or virtual entities and display that in the portal? Sorry, when you say integrate, what do you mean by integration? I want my phone also to connect to ServiceNow and let me create a ticket in ServiceNow.

Does ServiceNow have API? I mean, it depends how you're building your portal pages. You can obviously build some. I'll give you an example. So for one of the customers...

they are in property business, so they have image-heavy portal, right? It's very heavy. Imagine the property images, multiple property and so on, thumbnails, different, you know, different sizes, different ratios for the images, high-quality images, so a lot, right? So gigabytes of images, basically, we're talking about. We need to be able to scale them, allow people to upload, allow people to resize, to edit, change ratio, crop, all this sort of stuff.

Basically, portals have very limited support for that kind of operations. There is attachment support, but it's limited. We tried. It doesn't perform that well when you're talking about dozens and hundreds of images. So we switched to external service provider that specializes in serving images for industries like property rentals and things like that. So we switched to that and we integrated. And basically, it's just JavaScript.

Some work in JavaScript, either using jQuery or React or whatever your favorite framework is. Marketing portals, they use Angular, for example. So whatever your favorite framework is, you're fine. So that's one way you integrate on the front end. You kind of bring external services at the front end. If you're interested in the backend integration, then remember this, you probably heard the companion app, the notion that's been in place for a long, long time. But now it's official because portals support authentication. Portals can be themselves identity server. I really need to kind of...

create a series of small parts that explain people exactly what that means and how does it work. The idea is that you can create a web app, completely independent of the portals, that will use portals effectively for authentication or will use the same authentication mechanism as portals. Let's say portals use Azure ADP2C. Your web app can use Azure ADP2C. When someone logs in into your app, you will know the portal identity of that user. So you will know the context inside the portal.

So you'll be able to embed iframe, for example, these services inside your portals, and the identity will kind of flow on, so you will know who the contact is. And you can transfer between the portal and your website, and you will know who the user is. So that's kind of integration, kind of either embedded or kind of flow-like integration, the process integration, which gives you ability to deploy external sites. So that's kind of loose integration. Because portals doesn't do everything you need it to do. Correct. Portals are what it's good for, and then build an Azure web app or something. Yeah.

The last but not least, what you mentioned is kind of working with virtual entities. Not so much virtual entities, but talking about FinOps. If you go to the portal types and you start provisioning a portal, one of the portal templates would be the FNO template. And I don't have FNO, so I can't provision that. But the idea is that you use the dual write. It's still right, yeah. So effectively, you have either virtual or other entities or physical entities that tie back to whatever you have and bring it all together. So there's multiple options to integrate. And Web API, the portal Web API, it kind of gives us ability to create a powerful integrations where the portal code or front end talks to the back end. So they opened it up.

You were able to do it before. It's just you had to hide your whole code inside plugins and things like that. So it wasn't impossible, but definitely not the front-end developer friendly. So someone like Andrew, who is good at front-end, well, he's good at back-end as well, but let's assume he's not. So he would be then the front-end developer who needs to talk to the web API. And the only way to talk to it before that was through the back-end. Now we have direct way to talk to it. So we've gone from high code to code.

Or not to low code, was it yet? I don't think it's ever going to happen for the portals. I mean, portals are already low code. So I'm not sure that we can get any lower than that. Like you have entity forms and you have web forms and you have entity lists. So that's as low code as it gets. I mean, what a lot of people assume because it's called Power Apps Portals is that I can use connectors and do components and Canvas app stuff in a portal. Not yet. Not yet. George, this has been fun. Thank you for clarifying.

what that means, since Sean and I didn't know what we were talking about, about the portals last week. So thanks for joining us on CRM Audio. Well, you're welcome. And as you can see, I didn't know much what I'm talking about either. Check the show notes if you want the official answer.

Frequently asked questions

How long is this episode of CRM Audio?

This episode is 22 minutes long.

When was this CRM Audio episode published?

This episode was published on July 21, 2020.

Is there a transcript available for this episode?

Yes, a full transcript is available for this episode. You can read the complete transcript on the episode page.

Can I download this CRM Audio episode?

Yes. Use the download control on the episode player to save the publisher-provided media file.