01.06.2009, 18:07 | #1 |
Участник
|
Новый Task
Пытаюсь создать новый тас программно в новом приложении,помещенном в C:\Program Files\Microsoft Dynamics CRM Server\CRMWeb\ISV.
код добавления.. Код: CrmAuthenticationToken token = new CrmAuthenticationToken(); token.OrganizationName = sOrgname; token.AuthenticationType = 0; //Create the Service CrmService crmService = new CrmService(); crmService.Credentials = System.Net.CredentialCache.DefaultCredentials; //crmService.Credentials = new System.Net.NetworkCredential("administrator", "pass@word1", "LITWAREINC"); crmService.CrmAuthenticationTokenValue = token; string crmurl = (string)(Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\MSCRM").GetValue("ServerUrl")) + "/2007/crmservice.asmx"; crmService.Url = crmurl; // string sType = string.Empty; string sId = string.Empty; if(Request.Params["typename"]!=null) { sType = Request.Params["typename"]; sId = Request.Params["id"]; txtNotes.Text = "sType-" + sType; txtNotes.Text += "sId-" + sId; Microsoft.Crm.Sdk.Query.ColumnSet cols = new Microsoft.Crm.Sdk.Query.ColumnSet(); //cols.Attributes = new ArrayList(); cols.Attributes.Add("subject"); Guid gId = new Guid(sId); lead oLead = (lead)crmService.Retrieve(sType, gId, cols); txtNotes.Text += "oLead.subject-" + oLead.subject; string ssubject = oLead.subject; task t = new task(); //t.prioritycode = new PickList(); //t.prioritycode.Value = Convert.ToInt32("0"); t.subject = "my first task"; t.description = "my first task description"; t.scheduledstart = new CrmDateTime(); t.scheduledstart.Value = DateTime.Now.ToString(); t.scheduledend = new CrmDateTime(); t.scheduledend.Value = DateTime.Now.ToString(); t.regardingobjectid = new Lookup(); //t.regardingobjectid.name = "my name"; t.regardingobjectid.type = EntityName.lead.ToString(); t.regardingobjectid.Value = gId; //t.ownerid = new Owner(); //t.ownerid.name = "my name"; //t.ownerid.type = "type of object"; //t.ownerid.Value = new Guid(); t.scheduleddurationminutes = new CrmNumber(); t.scheduleddurationminutes.Value = 45; Guid gTSKId=new Guid(); try { gTSKId = crmService.Create(t); } catch (System.Web.Services.Protocols.SoapException ex) { txtNotes.Text += ex.Detail.InnerText; } txtNotes.Text+= "gTSKId-" + gTSKId.ToString(); if(gTSKId!=Guid.Empty) { SetStateTaskRequest tr = new SetStateTaskRequest(); tr.EntityId = gTSKId; tr.TaskState = new TaskState(); tr.TaskState = TaskState.Completed; //(or Canceled,Open); tr.TaskStatus = -1; //(set this to -1 so that CRM can decide the appropriate status.) crmService.Execute(tr); } Единственный толковый ресурс откуда я в общем-то и взял весь код это http://mymscrm3.blogspot.com/2007/12...in-crm-30.html |
|
|
Похожие темы | ||||
Тема | Ответов | |||
Новый пользователь из другого домена | 27 | |||
Как лучше реализовать? Создать новый объект или... | 12 | |||
Plugin на для обновления задачи (Task) | 14 | |||
связь через новый объект | 3 | |||
связь через новый объект | 0 |
|