javascriptdynamics-crm-2011xrmxrmservicetoolkit

Why my code not able to add activity?


I am trying to add phonecall activity for contact. I used following code to add activity, but I cannot see it in activity list.

var ContactId = guid; //Contact GUID

var trigger = new XrmServiceToolkit.Soap.BusinessEntity("phonecall");
trigger.attributes["subject"] = "Hello";
trigger.attributes["regardingobjectid"] =
                     { id: ContactId, logicalName: "Contact", type: "EntityReference" };

triggerId = XrmServiceToolkit.Soap.Create(trigger);

}

Kindly suggest if I am missing anything.


Solution

  • You need to pass in contact as the logicalName. This:

    { id: ContactId, logicalName: "Contact", type: "EntityReference" };
    

    should be:

    { id: ContactId, logicalName: "contact", type: "EntityReference" };