hello everyone,
i am trying to create a phone call task after creating an opportunity but the problem i need to populate a lookup field called "to" from the account lookup field that located in opportunity "parentaccountid" here is my code:
{ // TODO: Implement your custom Plug-in business logic. // QueryExpression query = new QueryExpression("opportunity"); // query.ColumnSet.AddColumn("parentaccountid"); var accountLookup = (EntityReference)entity.Attributes["parentaccountid"]; var accountName = localContext.OrganizationService.Retrieve(accountLookup.LogicalName, accountLookup.Id, new ColumnSet(true)); Entity opportunityCall = new Entity("phonecall"); opportunityCall["description"] = "opprotunity forwaded call"; opportunityCall["scheduledend"] = DateTime.Now.AddDays(7);//"10/28/2017"; opportunityCall["directioncode"] = true; opportunityCall["to"] = new EntityReference("account", accountName.Id); if (localContext.PluginExecutionContext.OutputParameters.Contains("id")) { Guid regardingobjectid = new Guid(localContext.PluginExecutionContext.OutputParameters["id"].ToString()); string regardingobjectidType = "opportunity"; opportunityCall["regardingobjectid"] = new EntityReference(regardingobjectidType, regardingobjectid); } localContext.OrganizationService.Create(opportunityCall); }
plus the plugin creates two tasks ??
*This post is locked for comments