Find deprecated JS code used in your Dynamics 365 environment | Dynamics 365 v9 JS Validator tool | XrmToolBox

In this point in time where all developers are busy upgrading their Dynamics 365 JavaScript libraries to use the latest supported code.

Here’s an extremely handy tool by Michel Gueli (https://twitter.com/MichelGueli) called as ‘XrmToolBox.Dynamics365V9JavascriptValidator’

Dynamics 365 v9 JavaScript Validator in XrmToolBox

If you use XrmToolBox already, make sure you look for the below tool

  1. In Tool Library, search for Dynamics 365 JavaScript Validator and you’ll find this tool already.

  2. Once you find it, it’s pretty easy to use it.
    You’ll find it in the list of your tools as below



    Then, it’ll just Retrieve all the Resources first. This will take a minute or two depending on your environment.

  3. Once done, it’s best practice to already add all the code you want to analyze in 1 solution in your Dynamics 365 environment like so

  4. Now, in the tool , open the same solution so that you only focus on the JS files you need to work with.

  5. Once you open it up, you’ll find all you files listed below. Just double click one of them and you’ll find what all needs to be changed.

  6. Once you work your way up in the file by replacing the deprecated code, you can reload the solution again and find that there are no longer any warnings like on my other file below

NuGet Gallery Link: https://www.nuget.org/packages/XrmToolBox.Dynamics365V9JavascriptValidator/

Hope this was useful!!
In case you are looking for more XrmToolBox or Dynamics 365 related posts, please check below –

  1. Set Lookups in Xrm.WebApi D365 v9 correctly. Solving ‘Undeclared Property’ error
  2. Find Created On date of solution components in Solution Layers | Dynamics 365 [Quick Tip]
  3. Pass data to HTML Web Resource using browser’s sessionStorage in Dynamics 365 CE
  4. Pass Execution Context to JS Script function as a parameter from a Ribbon button in Dynamics 365 | Ribbon Workbench
  5. Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
  6. Import lookup referencing records together in Dynamics 365 CRM | [Linking related entity data during Excel Import]
  7. Mailbox Alerts Hide/Show behavior in Dynamics 365 CRM
  8. Enable/Disable the need to Approve Email for Mailboxes in Dynamics 365 CRM CE
  9. Debug Ribbon button customization using Command Checker in Dynamics 365 CE Unified Interface
  10. Get Dynamics 365 field metadata in a Canvas App using DataSourceInfo function | Common Data Service

Thank you!!

Advertisement

Pass data to HTML Web Resource using browser’s sessionStorage in Dynamics 365 CE

If you’re using Xrm.Navigation.openWebResource(webResourceName, windowOptions, data), you probably are already using ‘data’ to the HTML Web Resource you are opening.

Here, I’m using an alternate method. I use JSON to send my data since it is widely preferred and used. Basically, I’ll Stringify my JSON object and add it to session storage, then – retrieve it from sessionStorage and Parse is back to object.

 

Opening Web Resource

Now, in my example, I’m not passing my data in the ‘data’ parameter provided by Xrm.Navigation.openWebResource(), instead I’m putting it in JSON.

  1. Let’s say, somewhere in my code, I want to send out a JSON to the HTML Web Resource which will open in a new window.
    So, instead of passing ‘data’ to Xrm.Navigation.openWebResource(), I’ll simply do the following –
    First, create a JSON object of what I want to send as data.
    Then, I’ll use sessionStorage.setItem(“<key>”, JSONObject); to add it to the sessionStorage and then open the WebResource using Xrm.Navigation.openWebResource()
    storedInSession

Reading from Session Storage

Reading from sessionStorage is as easy as putting data into it. Just the reverse –

  1. Assuming you are familiar with HTML and JS references, make sure you have correctly referenced the JS file you want to use with your HTML. Provide the name of the Web Resource in which you have your JS code.
    fileReferrenced
  2. Once the HTML document is loaded (I prefer using JQuery here to put things into document), you can read the same using sessionStorage.getItem(“<Key>”);

    And then, JSON.parse() the object retrieved from sessionStorage.
    retrived

  3. Also, if you look at the Application tab in Dev Tools of your browser, you can check for Session Storage info.
    You’ll find the Item you stored to the session
    inApplication

That way, you can use sessionStorage to keep your data in the browser session if you don’t have any other concerns or reasons not to use sessionStorage.

 

Hope this helps!!

Fix Ribbon icons on the Unified Interface in D365 CE

So, since adoption of Unified Interface is growing, people are asking – “What happened to the Ribbon icons?”. Well, a simple answer to this is tweaking the implementation a little.

Typically, you have custom icons on your classic Web UI that look like this –
classicIcon

But the same looks like a puzzle piece in the Unified Interface –
puzzlePiece

So, here’s what you need to do. Icons on the Unified Interface take SVG format. You’ll need to take you existing PNG Web Resources

 

Creating SVG Icons

Like most online services or applications, you can easily convert images to SVG. In this example, I’m using this online tool – https://www.online-convert.com/

Or you can try this too which I found quite a few people recommended – https://www.syncfusion.com/downloads/metrostudio

For this example, I used https://convertio.co/png-svg/ And I got my converted SVG document downloaded.
Now, create a new Web Resource in SVG and Upload the same.
svgWebResource

Ribbon Workbench

Once your Web Resource for the SVG format is set, going back to your Ribbon Workbench customization work space, go to the Button where you wan to update the icon and select the SVG Web Resource under Modern Image as shown below

modernImage

Publish Changes and See

Once your customization are published, you can simply refresh and check that your image has been updated

converted
Note: An online converted might not give you an accurate image. However, it is best recommended to create SVGs on an app. I’ve heard recommendations about https://www.syncfusion.com/downloads/metrostudio

Hope this helps!

Dynamics 365 Solutions History – Keep track of your deployments

As you might have observed, newer updates to D365 are bringing out vital features which were much needed in Dynamics 365 are finally rolling out.

One such feature is Solution History!

As you can see in your SiteMap, you’ll see Solutions History has been added
sitemap

It gives you a summary what solutions were imported, exported or deleted.

summary

Where does this come from?

If you look at the Default Solution, this is coming from Virtual Entity Data Provider
dataprovider

Availability

My observation is that this is available for organizations from 9.1.0.1471 onward.

version

If you want to learn more about my Cloning and patching Solution, check my blog here – Using ‘Clone a Patch’ & ‘Clone Solution’ in D365 Solutions

Hope this helps.

Quickly use Email Signatures in D365

You can use Email Signature in D365 Emails as well. Here’s a quick tip on it to quickly create a Signature and use it.

As I write this blog, this feature is not yet available in the Unified Interface yet.

Create a Signature

  1. Navigate to Settings > Templates > Email Signatures
    insertsignaturefeature

  2. And create a New Signature as below
    newemailsignature
  3. Now, I save and close.
    emailsignaturesaved

Insert and use Signature

Now, when you write a new Email or this email in D356, you can select the signature as below –

  1. Select Insert Signature while working on the email
    insertinemail
  2. Select the Signature and click Select.
    selectsignature
  3. And the Signature appears.
    finalsignature

That was easy. 🙂

Create a New Record button for Activity Type entity using Ribbon Workbench: D365

Problem

Typically, when you create a new Activity type of entity and you want a Create button for the same, it just appears in the Other Activities fly-out button and not on the Main ribbon in Activities to be specific.

currentProblem

And you can’t simply drag it out in the Ribbon Workbench since it is a dynamic button.

dynamicMenu

So, in this blog, I’ll create a button to open a new Create record form for my Activity type of entity called Assignment.

Customization

  1. Create a new Solution in your D365 environment and only add Activity entity into it.
    createSolution
  2. Load this solution into Ribbon Workbench and on the Main ribbon, add a button and give it a Name and Icon
    Note: Since there was no space in the Activity Ribbon, I had to sacrifice on of the least used Activities I had.
    sacrificeButton
  3. On that, I created a new Command and provided the below parameters –
    commandParameters
    Make sure you enter the name of your entity in String Parameter shown above correctly, in my case, it is new_assignment.
  4. Attach this Command to the Button
    mapButton
  5. Now Publish and check.

Create Assignment Button in Action

Now, when I go to Activities, I see my button called Assignments

buttonAppears

 

And when I click it, it open the full form for the Assignment entity

newForm

Hope this was quick!

D365 Quick Tip: Rather Uninstall Plugin Profiler from the D365 Solutions

Often, I get annoyed when I finish debugging the plugin and want to uninstall the Plugin Profiler from the Plugin Registration Tool so that users can quickly go ahead and test out the fix, it takes longer in the tool for the Profiler to be uninstall.

uninstallFromTool

And if at times, there are bandwidth issues, the uninstall just times out giving you this error.

error

Solutions in D365

Same thing is available in your organization’s Solution as well.

Select it and Delete it. It happens in less time.
uninstallFromSolutions
confirm

As a test, I simply closed the browser window and solution was deleted later when I logged back in. Since it happens on the server.

Hope this quick tip saves a few minutes. 😊

D365 Quick Tip: Est. Revenue calculations on Opportunity

Here’s a quick tip! Either let the system calculate the revenue of the Opportunity based on the Product Line Items or you can enter yourself or add your own custom logic to it.

So, there is a field on the Opportunity entity of type TwoOptions – ‘isRevenueSystemCalculated

And, as self-explanatory as its name, it will let you either set your own Revenue calculations or pull it from the Opportunity Line Details

field

You can either put this field on the form to switch while working or use custom logic (or use Default Value) to be set and keep it hidden from the user as per you requirements.

For the purpose of this blog, I’ve kept it on the form.

System Calculated

When you select System Calculated, the Est. Revenue field is locked and the Revenue is calculated from the Product Line Items.
systemCalculated

User Provided

When you select User Provided, the Est. Revenue field is unlocked and the Est. Revenue is open to enter data into it.
userProvided

Pretty straight-forward! 😊

Accessing multiple occurrences of a field in Business Process Flow using JS in D365 CRM

While working with BPF fields using JavaScript, there can be instances where you might want to keep the field locked in a certain stage but unlocked in another stage. And using Xrm.Page.getControl(controlName) or for v9 – getFormContext.getControl(controlName) should differentiate between the 2 fields?

Let’s see what we need to do here.

Scenario

  1. Let’s say I want the users to enter Customer Need data in Develop Stage.
    unlockedField
  2. But, just view what data is present in Propose Stage shown below, not modify it. (I’ve just renamed the field to Summarize Customer Need instead)
    lockedFields

JavaScript Usage to access the Control

  1. Now, since the Summarize Customer Need field is the second time, using getFormContext.getControl(“header_process_customerneed”) will be fetched to disable the first field only i.e. Customer Need in Develop stage.
    unlockedField
  2. To access Summarize Customer Need, you need to append “_1” to the control name for the second occurrence. And _2 and so on for further occurrences.
    Here’s the sample code which I used to access Summarize Customer Need to access the second occurrence of the field and use setDisabled(true) to lock it –
    code3. And that way, you’ll be able to access Summarize Customer Need control and do your desired operation (like even make it hidden or visible depending on your scenario) –
    lockedFields
    Hope this helps!