USD – Do Search

Here I will explain the capabilities in Unified Service Desk (USD) to search for data.

First of all let’s consider when this might be needed. Let’s say you have an account loaded but would like to show details of the primary contact, maybe in the overview of the account session. To achieve this you’ll need to search for details about the primary contact.

The concept of a search is pretty straight forward. First of all create the search in Unified Service Desk, which is just a fetch xml query. Then call the search from an action. (Typically triggered when a tab loads.)

Step One – Create the Search

First within settings, under Unfied Service Desk you’ll find the entity searches option.

Within here you can create whatever searches you need. Let’s stick with the example of getting details for a primary contact.

The fetch XML needed to return details of a primary contact for an account is shown below. If (like me) you aren’t great at writing fetch xml from scratch, you can always generate this simply by using an advanced find. (And then make a few tweaks in notepad!) The tweaks are on this condition line.

<condition attribute="contactid" operator="eq" uiname="[[]x]" uitype="contact" value="{[[account.primarycontactid.Id]x]}" />

Here you can see that replacement parameters are being used in inject the name and id for the primary contact from the account record.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">

<entity name="contact">

<attribute name="fullname" />

<attribute name="telephone1" />

<attribute name="contactid" />

<attribute name="emailaddress1" />

<attribute name="address1_postalcode" />

<attribute name="address1_stateorprovince" />

<attribute name="address1_city" />

<attribute name="address1_composite" />

<order attribute="fullname" descending="false" />

<filter type="and">

<condition attribute="contactid" operator="eq" uiname="[[]x]" uitype="contact" value="{[[account.primarycontactid.Id]x]}" />




The search needed ends up looking like this ….

Step Two – Create / call an action to execute the search.

In this example, I’m going to do this directly from the debugger!! This is so I can show the results before and after calling the action. You’d obviously need to create an action and call with an appropriate event. In this example, you might want to call a search on primary contact from the BrowserDocumentComplete event of the account hosted control. So that you query the primary contact every time the account is loaded.

For this example, I am first going to load USD and start a session for an account. Also notice I have the debugger loaded! For information on using the debugger refer to my earlier posts.

Before doing anything, looking in the debugger under data parameters will show us that in addition to all the standard global stuff I have collection of parameters for account available. If you initially don’t see these, don’t forget that you need to click the refresh button to view the most recent parameters. Importantly, at this stage, I don’t have any contact data that I can reference.

So at this point in time I cannot reference any details about the primary contact within CRM. To do this you’ll need to trigger a “DoSearch” action from the hosted control used for global container. Below you can see how I have constructed an action call directly in the debugger to call the DoSearch action. Notice that the data parameter is “name=Primary Contact”. I called my entity search “Primary Contact” in step one.

Below you can see that having pressed play, the debugger has returned a success status.

Now if I return to my data parameters and refresh the screen. I will get the results below. I hope you can see that a contact collection is available giving me access to details regarding the primary contact. Within USD actions (etc) I can now use replacement parameters to access the primary contact details. Such as [[contact.fullname]+] will return me the name of the primary contact.

Assuming you’ll want to run this action from you application. You will need to create an action in USD that looks something like the one below. In my USD application this action is called from the BrowserDocumentComplete event on a hosted control called Account.

6 thoughts on “USD – Do Search

  1. Hi,

    First of all, like always, a verry instructive article.

    I also tried to test a case where the result of a DoSearch is a list of contact (or account). However, i couldn’t find how to set up a navigation rule to display the search result.

    Is it possible for you to point me in the right direction?

    Thx in advance.


    • Thanks for the comment. Window navigation rules for search and everything else pretty much work in the same way!

      The only difference is on the route logic in the navigation rule. Typically you will normally set the “from” field to be the hosted control from which the window is being loaded. With a search you leave the “from” field blank. And instead populate the “From Search” field with the name of the search that will trigger this rule.


  2. Pingback: USD – The Book | Microsoft Dynamics CRM and Unified Service Desk

  3. Pingback: USD – The Book - Microsoft Dynamics CRM Community

  4. Hello Neil,
    First of all I want to thank you for all your videos and tutorials. It’s really precious and very helpfull to learn how to use USD. I am trying to display a list of activities as a result of an entity search. I’ve set up the navigation rule as you said in the previous comment but it still doesn’t work. Can I have please a screenshot or something that could help me? Thank you in advance.


    • Thanks for reading my blog. Can you please expand on your requirement? You mention wanting to display a list of activities. I have only used the search to display one record returned. What are you trying to achieved?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s