Hi Experts,
I have a task , that i have created a custom button on case form and on click of that custom button my description field in case form is updated to "ABC" and getting saved.Now I am writing a Plugin on which that if the case description is updated to "ABC" then case status should be "cancelled" and new case should be created.
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
Entity Case_E = (Entity)context.InputParameters["Target"];
if (Case_E.LogicalName == "incident")
{
if (Case_E.Attributes.Contains("description"))
{
string entityDescription = Case_E["description"].ToString();
if (entityDescription == "ABC")
{
Case_E["statuscode"] = new OptionSetValue(100000000);
}
}
}
}
Entity case_new = new Entity("case creation");
case_new.Attributes["customerid"] = new EntityReference("account", accountid)
case_new["new_caserecordtype"] = new OptionSetValue(12345);
Service.Create(case_new);
Service.Update(Case_E);
}
}
}
I am unable to get how to create a new case with the customer lookup field filled in it(customer lookup field is referring account entity)