USD – Accessing Context Parameters in Custom Hosted Control

Leave a comment

In this post we will look at how to access context parameters in a custom hosted control in C#.

Create a new project in Visual Studio:

You will see:

Update the references using NuGet:

Compile, and deploy by copying the assembly to your USD client folder:

Now create a new Hosted Control in D365:

Fill out the fields:

Now start USD. Open the debugger, you will see the parameters under $Context:

Open the new hosted control through the debugger, default action.

In Visual Studio, attach the debugger to Unified Service Desk. With a breakpoint on the DesktopReady event, we can see the Context is being populated with our ForceChange key:


To add a new key and value to replacement parameters of our custom hosted control, we can use MergeReplacementParameter:

        protected override void DoAction(Microsoft.Uii.Csr.RequestActionEventArgs args)
            // Insert into the Context
            var data = new List { new LookupRequestItem("New Context Key", "New Context Value") };
            var r = (DynamicsCustomerRecord)localSession.Customer.DesktopCustomer;
            r.MergeReplacementParameter(ApplicationName, data);


In running this from DoAction, for example, This produces:



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 *