plug-in to update an arecord and assign it to the user
-
Tuesday, April 24, 2012 11:12 AM
hello everyone i had requirement to create an a plug-in the scenario is when user assign a record in record if the field assignedto="designer" i want to change it to 'CSR"
created "assign" message and post-operation on the plug-in but when debug the plug-in it is not executing the step coming to inputparameter and out of the loop an am understanding want to do guys if you have solution please help me code is here
////////////////plug-in code
private string assigned;
public void Execute(IServiceProvider serviceprovider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceprovider.GetService(typeof(IPluginExecutionContext));
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity )
{
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.LogicalName == "lead" && context.MessageName == "Assign")
{
Entity lead=new Entity();
if (entity.Attributes.Contains("new_assignedto"))
{
assigned = (string)entity.Attributes["new_assignedto"];
}
if (assigned == "Designer")
{
lead["new_assignedto"] = "CSR";
IOrganizationServiceFactory servicefactory = (IOrganizationServiceFactory)serviceprovider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = servicefactory.CreateOrganizationService(context.UserId);
service.Update(lead);
ms crm
All Replies
-
Tuesday, April 24, 2012 11:21 AMModerator
Hi,
In case of assign Target will be Monikar
you can refer : http://danielcai.blogspot.in/2010/02/use-crm-assign-message.html
Mahain : Check My Blog
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Proposed As Answer by Mahender PalMVP, Moderator Tuesday, April 24, 2012 11:23 AM
-
Tuesday, April 24, 2012 12:09 PMDude i do not want to assign based on the role when record is assign i want change the value in it like if assignedto="Designer" i want to change it to "CSR" that it there is no need of security roles in this
ms crm