Last year, I built out a simple approach for script management in Dynamics Portals, including a model for managing shared script modules and building common reusable validators across Portal components. I posted about some of this work in prior posts: Dynamics Portals Field Validation and Dynamics Portals Script Management.

That project began as an Adxstudio v7 project that we later upgraded to the Dynamics Portals online solution. The model for handling scripts and the helper methods around validation held up very well during the upgrade. We required only minor updates for very specific cases, such as how a tool tip rendered from Adxstudios v7 to the Dynamics Portals.

Since I wrote these posts, I took some time to rework these ideas into a shared solution and examples with the intention of sharing as an open source project.

I recently started a new Dynamics Portals project and we began implementing client side scripting, such as adding custom validators and hiding/showing items based on field values. This was a nice chance to test out the solution and it’s worked well so far. My teammate and I have even added some updates in the short time we’ve been testing and we’ve been able to add some complex validations in a very short amount of time.

Time to share!

As mentioned, I had plans to post this solution to GitHub and add some examples. I had hoped to post working samples on a shared Dynamics Portal, but that’s been delayed for a bit. Luckily, preparing for that deployment forced me to clean up the code, include comments for TypeScript Intellisense, and work up some quick samples.

So instead of waiting for an environment, I’ve decided to post the solution to GitHub with instructions for setup and use in your project and environment. Once I get a sample environment up that will stick around for more than a few months, I’ll update the repository with that information.

Quick overview

The current project posted on GitHub is a standard Visual Studio solution that includes the shared scripts in TypeScript format. The Wiki page includes some details on the solution setup and how to deploy to Portals. That’s a work in progress, so keep an eye out for updates!

As a brief overview, the core of the solution resides in three TypeScript modules:

  • Script – UI Utilities – Web Template.ts – contains some helper scripts for working with the Portals user interface, such as Tabs and Section display or attribute labels.
  • Script – Validators – Web Template.ts – contains helper scripts around the Portals validators, such as adding or removing validators. Also includes several specific validators such as restricting dates or checking the number of items in a sub-grid
  • Script – Common Utilities – Web Template.ts – contains some general helper scripts, such as regular expressions or checking strings for null or empty.

You can check out the repository here: DynamicsPortalScripts.

I’ll be updating this this repository documentation with more detail on the individual modules and usage examples. As my current project continues, I am sure we will uncover some issues, make revisions, and include some additions based on new scenarios. As we make these revisions and additions, I will be sure to sync them up with the GitHub repository.

Any comments, suggestions, and/or issues can be posted to the repository Issues section, or just drop me a line here!