Open a previously created plugin solution in Visual Studio.
Add the following private variable:
private Guid serviceEndpointId;
Ensure that the public constructor of your class accepts a string parameter called config and add the following code to you constructor:
if (string.IsNullOrEmpty(config) || !Guid.TryParse(config, out serviceEndpointId)) { throw new InvalidPluginExecutionException("Service endpoint ID should be passed as config."); }
In your Execute method add the following code:
var cloudService = (IServiceEndpointNotificationService)serviceProvider.GetService(typeof(IServiceEndpointNotificationService)); if (cloudService == null) throw new InvalidPluginExecutionException("Failed to retrieve the service bus service."); string response = cloudService.Execute(new EntityReference("serviceendpoint", serviceEndpointId), context);
Compile your code and register the assembly in your Dynamics 365 instance.
Using the Plug-in Registration Tool add a post-update step to your plugin with the following details: