07/16/2020

By  Hema Shamala | Reading time 5 mins

Updating JavaScript code in Dynamics CRM Made Easy for Developers

Why do we need JavaScript in D365 CRM?

It allows us to implement custom logic by using client-side scripting. We use JavaScript to implement custom logic. For example, getting data from another entity based on a field selection or applying field validation.

Why do we need to update JavaScript?

If the requirements changed, we need to update our JavaScript code.

How to change existing Web Resource JavaScript code?

To update the code, you don’t necessarily need to start from scratch. Chances are that you have invested a lot of time and resources into creating the Web Resources for the forms in your current CRM system and would like to be able to leverage those investments.

 

We have lots of different tools in XRM Toolbox which comes handy for performing the update. Let’s look at some of them in this blog.

15 Questions to Identify the Gaps in Your CRM Processes

CRM Checklist - AhaApps

Dynamics 365 V9 JavaScript Validator (by Michel Gueli)

https://www.xrmtoolbox.com/plugins/XrmToolBox.Dynamics365V9JavaScriptValidator/

 

This tool is used for validating all your scripts and provides detailed information on what has to be updated and shows all errors and warnings in your script.

 

Below are the steps to use this tool.

 

  • To get the list you just need to go to XRM Toolbox and connect to your Organization.
  • If you want to see the warnings from all solutions select all solutions or you can select a particular solution and click on retrieve web resources.
  • Now click on scan all or select some web resource and click scan selected.
  • Now you can see all the detailed warnings in the log.

 

Below is a screenshot that shows all the count and warnings in your scripts.

Updating JavaScript code in Dynamics CRM Made Easy for Developers - AhaApps

Script Finder

https://www.xrmtoolbox.com/plugins/MsCrmTools.ScriptsFinder/

 

This tool is used to list and update the form events for passing the executionContext, parameters and enable/disable the event in the form.

 

Below are the steps to use this tool.

 

  • To get the list you just need to go to XRM Toolbox and connect to your Organization.
  • If you want to see the Form Events, click on Find Script Usage and select an option for all entities or for entities in selected solution and click ok to retrieve all events.
  • You can also add filters by clicking on Show Filters.
  • Now select some event and you will be able to see the update properties at the bottom.
  • In the update Properties tab, you will be able to pass the executionContext, parameters and enable/disable the event in the form.
  • Click on save the properties will be updated in the CRM System.

 

Below is a screenshot of how the script finder looks.

Updating JavaScript code in Dynamics 365 Made Easy for Developers - AhaApps

JavaScript Migrator

https://d365geekstertips.wixsite.com/home/post/xrmtoolbox-javascrip-migrator-plugin

 

This tool is used to migrate your JavaScript, activate execution context for form and execution context for the ribbon. As shown in the below picture your code will be automatically generated when you select the file and if you click on update it will update in your CRM system with the latest code.

 

  • It helps you calculate the time (in hours) that the migration might take when it’s done manually.
  • It identifies the block of code that needs to be reviewed.
  • It analyzes the script and automates the following:
    • Highlighting/Replacing deprecated client APIs by the corresponding ones based on Microsoft recommendations.
    • Migrating all the functions and their contents.
  • It verifies the result and selects which scripts you wish to update.

 

Below are the steps to use this tool.

 

  • Install JavaScript Migrator plugin from XRM Toolbox plugins.
  • Retrieve the web resources from a specific solution you already prepared.
  • After selecting the solution, the tool will gather from the CRM, all the needed information: List of web resources, Entities metadata, Ribbon Events, and Form Events.
  • To update the web resource and its related events, you can choose between updating the elements directly, or adding them to a queue to be pushed later, after you have analyzed multiple scripts.
  • After adding multiple scripts to the queue, you can update all the web resources, with options you have chosen, by clicking on the update button

 

Below is a screenshot of how the JavaScript Migrator looks.

Dynamics 365 Java Script - AhaApps

You can also analyze all the web resources and get an estimation of the work amount that needs to be done (button Analyze/Export). The result can be extracted in an Excel file (the obtained estimations are in hours).

 

By using these tools developers can save a lot of time.

 

I hope you enjoyed this article and you are excited to start using these tools.

 

If you want to know more about Dynamics CRM and the way it can revolutionize your operations, connect with us today.

Author’s bio:

Hema is one of the Dynamics CRM superstars who has been associated with the AhaApps family since March 2018. She is always up for a challenge and executes her problem solving skills perfectly. When she isn’t wearing the Dynamics 365 Consultant’s hat on she loves to walk amidst nature or read up new and interesting articles. She loves to crack herself up as comedy is her favorite genre to watch.

Setting Up The “Follow” Functionality In Dynamics 365

How can you follow records for the out of box entities like leads, accounts, and contacts? Well, read our blog to find out.