I am trying to save Guid of Lead in Regarding Field of PhoneCall Activity, It gives an error like - "regardingobjectid" only. [On Premise]
Please Help!
In New_PhoneCall.cs Page :
PhoneCall_Save.regardingobjectid = Guid.Parse(hdnfld_regarding.Value); //(hdnfld_regarding is a hiddenfield in which m passing guid, which i have taken along with textbox)
In AppCode/CRMDMLibrary.cs :
public class PhoneEntity
{
public Guid regardingobjectid;
}
public bool SaveNewPhoneCall()
{
try
{
IOrganizationService Context = CRMDMLibrary.GetCRMService(url, DomainName, username, password);
Entity Phone = new Entity("phonecall");
Phone["regardingobjectid"] = new EntityReference("regardingobject", regardingobjectid);
Guid phoneid = Context.Create(Phone);
return true;
}
catch (Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
HttpContext.Current.Response.End();
return false;
}
}
Passing regardingobject as EntityReference is wrong.You should pass lead as EntityReference
Phone.Attributes["regardingobjectid"] = new EntityReference("lead", regardingobjectid);
Also Check that where lead id is coming from