Publishing Dataverse Events
Push events from Dataverse to external systems. Learn to publish events using IServiceEndpointNotificationService and the Plug-in Registration Tool, and choose the right listening strategy.
Sending events to the outside world
Think of publishing events like a news agency sending bulletins.
When something important happens in Dataverse, it can broadcast that event to external systems. There are two ways: automatically (configure it in PRT — no code) or programmatically (C# code using IServiceEndpointNotificationService for conditional publishing).
Two publishing approaches
| Feature | PRT Registration (No Code) | IServiceEndpointNotificationService (Code) |
|---|---|---|
| Setup | Configure in Plug-in Registration Tool | Write C# in a plug-in |
| Conditional publishing | No — publishes on every matching event | Yes — publish only when your code decides |
| Custom payload | Standard execution context | Execution context — you control WHEN to publish (the payload is still the context, enriched via shared variables) |
| Plug-in mode | N/A — configured via PRT step | Must be registered as an ASYNCHRONOUS plug-in |
| Best for | Simple event broadcasting | Conditional publishing, enriched payloads |
Code-based publishing
// IMPORTANT: This plug-in must be registered as ASYNCHRONOUS
public class ConditionalEventPublisher : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
var context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
Entity target = (Entity)context.InputParameters["Target"];
// Only publish if order value exceeds threshold
decimal orderValue = target.GetAttributeValue<Money>("totalamount")?.Value ?? 0;
if (orderValue > 10000)
{
var notificationService = (IServiceEndpointNotificationService)
serviceProvider.GetService(typeof(IServiceEndpointNotificationService));
Guid endpointId = new Guid("your-endpoint-id");
notificationService.Execute(
new EntityReference("serviceendpoint", endpointId), context);
}
}
}
Choosing a listening strategy
| Listener | Delivery | Reliability | Best For |
|---|---|---|---|
| Webhook | HTTP POST to URL | Low — lost if endpoint down | Simple notifications, low volume |
| Service Bus (Queue) | Message in queue | High — guaranteed delivery | Reliable processing, one consumer |
| Service Bus (Topic) | Message to topic | High — filtered subscriptions | Multiple subscribers |
| Event Hub | Event in stream | High — massive throughput | Telemetry, analytics, streaming |
| Power Automate | Flow trigger | Medium — built-in retry | Low-code reactions |
Exam tip: Webhook vs Service Bus
If the question mentions reliability, guaranteed delivery, or consumer might be offline — the answer is Service Bus. If it says simple notification to an always-available endpoint — webhook is fine.
A developer needs to publish Dataverse events to a warehouse system that may be offline for hours during maintenance. Which approach?
🎬 Video coming soon
Next up: Service Endpoints — configuring webhooks, Azure Service Bus, and Event Hub.