Tip #674: Dealing with multiple search results in Unified Service Desk

Too many search resultsUnified Service Desk has a concept of Entity Search, that allows you to store parameterized fetchxml and reuse this definition declaratively (say, in Windows Navigation Rules), or via DoSearch action of the Global Manager, or directly from your code.

One aspect that Entity Search does not deal well with is the searches returning multiple results. USD captures the first result only, indicates the total count in the $Return parameter and sets flag that more results are available. Documentation deflects to the “custom hosted controls”.

Dealing with multiple results is surprisingly simple. USD surfaces only the first result but captures all of them, and information is readily available.

protected override void DoAction(
      RequestActionEventArgs args)
{
  if (args.Action.Equals("DealWithMultipleResults", 
               StringComparison.OrdinalIgnoreCase))
  {
      var results = GetDesktopRecord().EntityResults;
      // results are List<Entity>, deal with it
      // e.g. bind it to the grid and pop the window 
      // in the FloatingPanel
  }
}

One thought on “Tip #674: Dealing with multiple search results in Unified Service Desk

  1. Derek says:

    Thanks. It is so frustrating that this documentation is no where to be found. USD docs are garbage.

Leave a Reply

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