Advertisements
Home > CRM > [Code Snippet] Dynamics Post Assign Plugin

[Code Snippet] Dynamics Post Assign Plugin

This article is a response to one of the blog questions. 

Below is the code snippet for Post Assign (i.e., Ownership change) plug-in.

In the ‘Post Assign’ plug-in you get 2

  • Current record as ‘Entity Reference’ in ‘Target‘ attribute.
  • Records new Owner (i.e., Owner or Team) in the ‘Assignee‘ attribute.

EntityReference entRefCurrentRecord = null;
EntityReference entRefAssignee = null;

// Get current record as Entity Reference
if ((context.InputParameters.Contains(“Target”)) && (context.InputParameters[“Target”] is EntityReference))
{
entRefCurrentRecord = (EntityReference)context.InputParameters[“Target“];
}

// Get User/Team whom the record assigned to from ‘Assignee’ property of Context
if ((context.InputParameters.Contains(“Assignee”)) && (context.InputParameters[“Assignee”] is EntityReference))
{
entRefAssignee = (EntityReference)context.InputParameters[“Assignee“];
}

// Write your business logic

  • You might want to register Pre/Post images on the Plug-in step, to read other attributes of the record.

🙂

Advertisements
Categories: CRM Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: