[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.
🙂