Call an Event in USD from JavaScript

Leave a comment

In Unified Service Desk, we have the ability to call Events from JavaScript. Here we will go through an example.

In our USD, when an Incident is selected from a Dashboard, it starts a new session. Let’s say when an incident is opened, and the user enters something in the description field. For example, if the title of the incident is “User cannot log into CRM”, the agent might type into the description some notes such as “User gets incorrect password error in Dynamics 365”.

Let’s say we add some JavaScript to our incident form. On the change event of the description field, we will call an event in USD that will search for the description and open the web page to display the results in a new tab.

First, we will create a new hosted control to display the web page of type Standard Web Application:

Next, we will create an event in the Incidents hosted control. This event will be called by our JavaScript code later. Note the JavaScript code call will run the event against the control we are calling it from, Incidents:

Give the event a name, e.g. NavigateToGoogle, and click to add an action:

Add a new action. In our case, the action will load google in the Google hosted control we created. Notice we will pass the [[description]] to the web URL. We will set that in the JavaScript later:

Once the action is saved, add it to our Event on the Incident:

Now, the JavaScript. We will register an event on the changing of the description field:

In the JavaScript, we will ge the value of the description field entered, and pass it to http://event. We will append description to the URL:

function CaseDescription_OnChange () {
  var CaseDescription = Xrm.Page.getAttribute("description").getValue();
  if(window.IsUSD == true) {"http://event/?eventname=NavigateToGoogle&description='" + CaseDescription + "'");

Now, test the code. Open an incident in USD and enter a description:

A new Google tab will open, displaying the results of what was entered in the description:



Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube


Leave a Reply

Your email address will not be published. Required fields are marked *