DEV Community

Cover image for Form-based Dataverse Web Resources with React, Typescript and FluentUI - Part 2
Riccardo Gregori
Riccardo Gregori

Posted on

4

Form-based Dataverse Web Resources with React, Typescript and FluentUI - Part 2

A few months ago I posted this article on how to develop form-based HTML WebResources leveraging my npm package @_neronotte/cra-template-dataverse-webresource, and it generated a lot of interactions.

In that article I've shown how to:

  1. create a standard React+TS+FluentUI WebResource using my npm package
  2. remove the references to ClientGlobalContext.js.aspx
  3. update the index.tsx file to accept Xrm and FormContext from the parent form
  4. update the local SDK removing dependencies from GlobalContext and adding the LocalFormContext class
  5. build and push to Dataverse
  6. edit the form js to inject the context into the webresource.

Nothing so much complicated... but quite manual.

Since then, I had the opportunity (or need, see it as you like) to create several WebResources that needed to be embedded into forms and... as usual... when I'm stuck on doing manual stuff 3 times in a row or more, i try to automate it as much as possible.

Let's do it! πŸš€

The output of this job is here: this new npm package is a clone of the previous one that addresses automatically steps 2 to 4 of the previous list and provides a few improvements, such as

  • css is now managed internally to the .tsx file with FluentUI makeStyles
  • css sizes, positions, colors, borders and fonts are handled via FluentUI tokens in order to reflect the standard theme, and designed to fit well in a form section (playing with tokens I've found a lot of interesting stuff... more on this topic in one of the upcoming posts)

makeStyles and tokens

  • the render() call is done automatically on start when running the webresource in development mode via npm run start

render() call

  • icons dependency migrated from legacy Fluent 8 icons to new Fluent 9 icons

Icons dependency

So... no more manual job needed, you can just create your WebResource with:

npx create-react-app <name> --template @_neronotte/cra-template-dataverse-webresource-form
Enter fullscreen mode Exit fullscreen mode

And you're ready to go!

Conclusions πŸ‘πŸ»

With this new package WebResource development is streamlined even more than before! Tell me what do you think about it, drop a comment here or on my LinkedIn page.

The source code of the create-react-app template is open source and available on GitHub, feel free to ping me there for issues or new feature requests.

Hope this will be helpful to you as much as it is for me!

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo πŸ“Šβœ¨

Top comments (0)

Image of Stellar post

Discover what it takes to launch a Web3 startup

Bringing your Web3 idea to life and launching a startup can be a difficult, complicated process. Check out the Stellar Dev Diaries to learn from a team that is makiung it happen, in real time!

Learn more

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❀️