…Using tools and SDKs that you work with end-to-end

By Steve Drake, Director, Technology at TrueNorth IT.

In the past we have built CRM (Dataverse) portals using Microsoft’s PowerApps Portals. We have even blogged about it.

But often you cannot deliver exactly what the user wants with PowerApps Portals. Sometimes we need a more code-focused solution and one that our Dataverse developers will be familiar with.

What do our Dataverse Developers Know?

JavaScript, TypeScript, JavaScript and JavaScript … With Dataverse you can customise your forms with JavaScript; you can also make data calls to the Dataverse with JavaScript via the ODATA SDK.

TypeScript is a subset of JavaScript and lets users write code with type checks, as well as a few other neat language features.

Did you say NODEJS?

Our devs know JavaScript so… our devs know JavaScript, they understand the Dataverse SDK and they have consumed it from JavaScript in the past. Can we reuse that knowledge? Can we write JavaScript code that consumes the CRM SDK to produce data for our HTML forms? Well we can, and it’s pretty simple to do, it’s just an ODATA endpoint. We have found the NPM package DynamicsWebApi to be pretty useful.

We can write code in JavaScript that will read data from the Dataverse and produce a nice representation of the data for the JavaScript in our HTML app to consume.

The following code will read Global OptionSet from the DataVerse:

Dataverse-portal-from-code-

And, if we want it to run from an Azure Function running NODEJS, it’s just:

Dataverse-portal--2

Yes, it’s really that simple.

What about the frontend?

Most developers who can build websites will have a chosen framework: Vue, React or Angular. Any of these can be used to build a rich web application and any of these can consume our very simple NODEJS API. It’s just very basic REST HTTP calls.

Why not go direct to CRM?

We could go direct to CRM from our website, but this would be insecure in some cases.

What about hosting?

Microsoft have just launched Azure Static Web Apps. These let you host a single page application website, along with an API built with Azure Functions, for about £5 per month!!! That £5 per month includes compute time to execute the functions. If you need more, such as durable functions, then you can host them yourself on their own Azure Function resources. If we continue with the serverless model your costs will not jump up, we can still keep the costs to less than £10 per month for most basic portals.

And what about security?

With this approach, the Azure Functions connect to the Dataverse using an application account, so you can restrict what the API can consume with standard security roles. The NODEJS API can add further filtering based on the user’s interaction with the API. For some projects, it’s a public API, but often it’s protected with a simple login. When we have a user context we can add filtering based on the user interacting with the API. Maybe they can only view forms they submitted, maybe they can re-submit a form after it’s been rejected, or maybe they can see the status of a form.

Non-technical overview

Using this code-first approach, your development team are happy with Dataverse development, and are happy to build web applications that use JavaScript. This development team can work together to create rich portals that access data from the Dataverse with JavaScript, using the skills they have learnt.

More reading

To get started with Azure Functions, have a look at have a look at this Microsoft guide.

Get our latest articles in your inbox

Enjoyed this article? Sign up for our email newsletter and get real-world information on all things Microsoft, cloud and tech. Your information will be shared with MailChimp but no one else, and you can unsubscribe with one click at any time