Below is some example C# code that shows how to add a communication of type "Task" using the SOAP web service interface.


ewarebase[] CRMBase = new ewarebase[1];
communication newTask = new communication();
newTask.action = "ToDo";
newTask.type = "Task";
newTask.channelid = 1;
newTask.channelidSpecified = true;
newTask.status = "Pending";
newTask.priority = "Normal";
newTask.note = "Note: Test6";
newTask.description = "Description: Test6";
 
newTask.datetime = DateTime.Now;
newTask.datetimeSpecified = true;
 
CRMBase[0] = newTask;
addresult CRMAddResult = CRMbinding.add("communication", CRMBase);
crmid newCommID = (crmid)CRMAddResult.records[0];
 
comm_link newLink = new comm_link();
newLink.comm_communicationid = newCommID.crmid1;
newLink.comm_communicationidSpecified = true;
newLink.comm_companyid = 28;
newLink.comm_companyidSpecified = true;
newLink.comm_personid = 30;
newLink.comm_personidSpecified = true;
newLink.comm_userid = 4;
newLink.comm_useridSpecified = true;
 
CRMBase[0] = newLink;
addresult CRMLinkAddResult = CRMbinding.add("comm_link", CRMBase);

Notes:

This has required two records to be inserted into the system.  A communication record and an communication link (comm_link) record.  Comm_link is a secondary entity that has the job of linking the Communication (Task) with the person assigned to do it and the company and person records.  

Values have been hard coded for the Team(channelid), Company, Person and Assigned User. 

If the task is linked to an opportunity/case/solution/lead/waveitem then the link is through a foreign key on the communication table in the same way that the communication is assigned to a team.


newTask.channelid = 1;
newTask.channelidSpecified = true;
 

or

 


newTask.solutionid = 1;
newTask.solutionidSpecified = true;
 

If the Task is being linked to a custom entity then it would need to be referenced in the same way.
If the the communication is successfully added to the database then the result set contains the ID of the record added.  This can then be passed to the comm_link record.

crmid newCommID = (crmid)CRMAddResult.records[0];
newLink.comm_communicationid = newCommID.crmid1;
 
Dates have to be specified

newTask.datetime = DateTime.Now;
newTask.datetimeSpecified = true;
 
And you can offset dates using standard date behviour

newTask.todatetime=DateTime.Now.AddHours(2);
newTask.todatetimeSpecified=true;