I need to create plugin for Dynamics CRM Online wich randomly change company name after editing the contact's fields. As i know i need to change parentcustomerid field, but i dont know how to get all customer IDs аnd assign one of them in plugin's code.
My code:
public class ContactPlugin: IPlugin
{
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 == "contact")
{
//entity.Attributes.Add("parentcustomerid", GetNewParentCustomerId());
}
}
}
}
How can i do that?