Skip to main content

Essential Dynamics 365 Plugins for Sales & Customer Service

Introduction

In Dynamics 365, plugins automate business processes, enforce rules, and ensure data integrity. Whether in Sales or Customer Service, plugins help streamline workflows by executing logic at the right time in the pipeline.



This post covers key plugin scenarios, detailing:
Execution pipeline stage (Pre-Validation, Pre-Operation, Post-Operation)
Synchronous or Asynchronous execution
Pre-Image / Post-Image usage
Rollback handling


Rollback Handling in Plugins

When Does a Plugin Rollback?

A plugin automatically rolls back if:

  • An exception is thrown in a synchronous plugin.
  • A transaction fails in a Pre-Validation or Pre-Operation stage.

How to Handle Rollbacks?

  • Use Try-Catch Blocks: Prevent unwanted failures by catching errors and logging details.
  • Throw an Exception When Needed: Stop invalid data changes (e.g., prevent closing an Opportunity without a Quote).
  • Compensating Logic in Async Plugins: Since Post-Operation Async plugins do not participate in transactions, write logic to revert changes if required.
Here is some in detail explanation about pipeline stages.




Sales: Automating Lead to Cash Processes



Create Scenarios

  1. Auto-Assign a Sales Rep When a New Lead Is Created

    • Pipeline Execution: Pre-Operation
    • Execution Mode: Synchronous
    • Image to Use: N/A
    • Rollback Handling: If an error occurs, the Lead won’t be created.
  2. Create a Task for Follow-Up When an Opportunity Is Created

    • Pipeline Execution: Post-Operation
    • Execution Mode: Asynchronous
    • Image to Use: Post-Image
    • Rollback Handling: If the Task creation fails, the Opportunity remains but without a follow-up task.

Update Scenarios

  1. Update Opportunity Status Based on Quote Approval

    • Pipeline Execution: Post-Operation
    • Execution Mode: Synchronous
    • Image to Use: Pre-Image & Post-Image
    • Rollback Handling: If the update fails, the status change is rolled back.
  2. Recalculate Estimated Revenue When Products Are Updated in an Opportunity

    • Pipeline Execution: Post-Operation
    • Execution Mode: Synchronous
    • Image to Use: Pre-Image & Post-Image
    • Rollback Handling: If an error occurs, the previous revenue calculation remains unchanged.

Delete Scenarios

  1. Prevent Deleting a Lead If There Are Related Activities

    • Pipeline Execution: Pre-Validation
    • Execution Mode: Synchronous
    • Image to Use: Pre-Image
    • Rollback Handling: If an exception is thrown, the Lead deletion is fully rolled back.
  2. Automatically Reassign Open Opportunities If a Sales Rep Leaves

    • Pipeline Execution: Post-Operation
    • Execution Mode: Asynchronous
    • Image to Use: Pre-Image
    • Rollback Handling: As an async plugin, failure won’t rollback the user deactivation. Consider logging failures and retrying.

Customer Service: Enhancing Case Management



Create Scenarios

  1. Auto-Assign Case to a Queue When Created

    • Pipeline Execution: Pre-Operation
    • Execution Mode: Synchronous
    • Image to Use: N/A
    • Rollback Handling: If an error occurs, the Case won’t be created.
  2. Create a Customer Notification When a Case Is Created

    • Pipeline Execution: Post-Operation
    • Execution Mode: Asynchronous
    • Image to Use: Post-Image
    • Rollback Handling: If the email fails, the Case is still created, but no notification is sent.

Update Scenarios

  1. Escalate Cases That Are Open for More Than 48 Hours

    • Pipeline Execution: Post-Operation
    • Execution Mode: Asynchronous
    • Image to Use: Pre-Image & Post-Image
    • Rollback Handling: Since this is async, failure won’t rollback the Case update but should be logged.
  2. Prevent Closing a Case If There Are Open Activities

    • Pipeline Execution: Pre-Validation
    • Execution Mode: Synchronous
    • Image to Use: Pre-Image
    • Rollback Handling: If an exception is thrown, the Case remains open.

Delete Scenarios

  1. Restrict Deleting Cases That Have a Resolution Logged

    • Pipeline Execution: Pre-Validation
    • Execution Mode: Synchronous
    • Image to Use: Pre-Image
    • Rollback Handling: If an exception is thrown, the Case deletion is fully rolled back.
  2. Automatically Close All Open Tasks When a Case Is Deleted

    • Pipeline Execution: Post-Operation
    • Execution Mode: Asynchronous
    • Image to Use: Pre-Image
    • Rollback Handling: If task closure fails, the Case is still deleted, leaving orphaned records. Consider using transactions or compensating logic.

Each plugin scenario ensures smooth business operations, executing at the right stage in the pipeline, with appropriate synchronous or asynchronous execution, and leveraging rollback mechanisms when necessary.

By implementing these Sales and Customer Service plugins, organizations can enhance automation, enforce business rules, and improve data consistency in Dynamics 365.

Want to see detailed C# implementations of these plugins? Comment or let me know on my LinkedIn profile : Pavan Kumar Vuyyuru

Comments

Popular posts from this blog

Powerapps: Collections in Canvas Apps | Collect, ClearCollect, Clear in Powerapps

Collections : Collections are special types of variables or data storage mechanism which can be used to manipulate the data within Power Apps.  Collections are usually a group of similar items which acts like a table of values with columns and rows.  We can create, update, delete, use it as the data source for a gallery to view the items within Power App.  Collect, Clear, and ClearCollect functions:   Collect : In Power Apps, the Collect function is used to create or update a collection in your app.  Collections are temporary data sources that allow you to store and work with data within your app.  The Collect function is versatile and can be used in various scenarios to add, modify, or remove records from a collection.  Syntax : Collect( IceCream, { Flavor: "Pistachio", Quantity: 40 }, { Flavor: "Orange", Quantity: 200 } )   Adds two records to the IceCream collection that includes a quantity of pistachio and orange ice cream.  Clear : In Po...

Understanding the Basics of C# Plugins in Dynamics 365: A Simple Account Update Example

Welcome to my blog! Today, we’ll dive into the world of C# plugins in Dynamics 365. If you're working with Dynamics 365, you’ve likely heard of plugins, which allow you to extend the platform's functionality and automate various processes. In this post, I’ll walk you through the parts of a plugin, using a simple example of updating an account record. What Is a C# Plugin? A plugin in Dynamics 365 is a custom business logic component that responds to specific events in the system. Plugins are executed in response to a trigger event, like creating or updating a record, and can be used to modify data or integrate with other systems. Written in C#, they are powerful tools for customizing and extending the functionality of Dynamics 365. The Structure of a C# Plugin A plugin typically consists of several parts: Plugin Registration – You register the plugin in Dynamics 365 to define what event triggers the plugin (create, update, delete) and which entity it will affect (e.g., A...