USD Custom Hosted Control with Visual Studio 2019

Leave a comment

In this post, we will create a USD Custom Hosted Control using Visual Studio 2019. This control will be used to receive Actions from USD, and can then be used to do things when the action is involved. There is no UI for this control, consider it is a “lite” control.

We will run this on USD 4.1.

First, open Visual Studio and create a new Class Library of .NET Framework version 4.6.2:

We see:

Let’s add a reference to Microsoft.CrmSdk.USD.CoreAssemblies through NuGet:

We see:

We get the warning “There was a mismatch between the processor architecture of the project being built” below. We can ignore this:

Let’s add a reference to WindowsBase:

Now let’s add a using statement for:

using Microsoft.Crm.UnifiedServiceDesk.Dynamics;

Rename the class TestControl.

And we will implement DynamicsBaseHostedControl. Press CTRL + “.” to generate the method TestControl:

Let’s override the DoAction method:

protected override void DoAction(Microsoft.Uii.Csr.RequestActionEventArgs args)
{
if (args.Action.Equals("DoSomething", StringComparison.OrdinalIgnoreCase))
{

}
}

Now, compile the assembly and copy it to the folder where you run USD.

In Debug, set the External Program to the USD executable:

Add breakpoints in the code:

In the USD configuration:

  • Create a hosted control

  • Create an action called DoSomething

  • Create an action call to call DoSomething

  • Call the action call. We will do this on a routing rule:

Click Start. This will open USD.

When USD loads, the first breakpoint is hit:

Now invoke the action by running the routing rule. The breakpoint is hit:

 

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

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 *