private static void AttachNotesToRecordUsingCreateAnnotation(CrmServiceClient crmSvc, Guid RecordID) { Dictionary <string, CrmDataTypeWrapper> inData = new Dictionary <string, CrmDataTypeWrapper>(); inData.Add("subject", new CrmDataTypeWrapper("This is a NOTE from the API", CrmFieldType.String)); inData.Add("notetext", new CrmDataTypeWrapper("This is text that will go in the body of the note", CrmFieldType.String)); crmSvc.CreateAnnotation("account", RecordID, inData); }
public void CreateAnnotationTest() { OrganizationRequest orgReq = null; Guid respId = Guid.NewGuid(); MCreateResponse orgResp = new MCreateResponse(); orgResp.idGet = () => respId; BCrmServiceClient.AddResponse(typeof(CreateRequest), orgResp); BCrmServiceClient.MockCrmCommandExecute(); MCrmWebSvc.AllInstances.CrmUserGet = (websvc) => new WhoAmIResponse(); Dictionary <string, CrmDataTypeWrapper> newFields = new Dictionary <string, CrmDataTypeWrapper>(); newFields.Add("name", new CrmDataTypeWrapper("CrudTestAccount", CrmFieldType.String)); newFields.Add("accountnumber", new CrmDataTypeWrapper("12345", CrmFieldType.String)); newFields.Add("telephone1", new CrmDataTypeWrapper("555-555-5555", CrmFieldType.String)); newFields.Add("donotpostalmail", new CrmDataTypeWrapper(true, CrmFieldType.CrmBoolean)); Guid result = crmaction.CreateAnnotation("account", respId, newFields); Assert.AreEqual(result, respId); result = crmaction.CreateAnnotation("", respId, new Dictionary <string, CrmDataTypeWrapper>()); Assert.AreNotEqual(result, respId); orgReq = BCrmServiceClient.GetRequest(typeof(CreateRequest)); Assert.IsNotNull(((CreateRequest)orgReq).Target); }
private static void ImportWebFiles(CrmServiceClient svc, string sourcePath) { var mapObj = new[] { new { FileName = "", WebFileId = "" } }; var mapListPath = sourcePath + "/mapList.json"; if (!File.Exists(sourcePath + "/mapList.json")) { throw new Exception("Lock off mapList.json"); } var mapList = JsonConvert.DeserializeAnonymousType(File.ReadAllText(mapListPath), mapObj); var files = new DirectoryInfo(sourcePath).GetFiles().ToDictionary(x => x.Name); foreach (var map in mapList) { var updateData = new Dictionary <string, CrmDataTypeWrapper> { { "documentbody", new CrmDataTypeWrapper(Convert.ToBase64String(File.ReadAllBytes(files[map.FileName].FullName)), CrmFieldType.String) }, { "filename", new CrmDataTypeWrapper(map.FileName, CrmFieldType.String) } }; svc.CreateAnnotation("adx_webfile", Guid.Parse(map.WebFileId), updateData); } }