/// <summary> /// Saves and retrieves contact with a custom field. /// </summary> public static void Example2() { var customContact = new CustomContactRequest { ContactType = ContactType.Individual, Gender = Gender.Male, FirstName = "Will", LastName = "Tura", GapId = 797204 }; using (var channelFactory = new ChannelFactory <ICiviCrmApi>("*")) { using (var channel = channelFactory.CreateChannel()) { var result1 = channel.ContactSave(ApiKey, SiteKey, customContact); Debug.Assert(result1.Id.HasValue); // Custom fields don't come by default for contacts. So we have to specify ReturnFields. var result2 = channel.GetSingle(ApiKey, SiteKey, CiviEntity.Contact, new IdRequest { Id = result1.Id.Value, ReturnFields = "custom_10,first_name,last_name" }) as JObject; Debug.Assert(result2 != null); var contact = result2.ToObject <CustomContact>(); Console.WriteLine("{0} {1} ({2})", contact.FirstName, contact.LastName, contact.GapId); } } }
/// <summary> /// Saves and retrieves contact with a custom field. /// </summary> public static void Example2() { var customContact = new CustomContactRequest { ContactType = ContactType.Individual, Gender = Gender.Male, FirstName = "Will", LastName = "Tura", GapId = 797204 }; using (var channelFactory = new ChannelFactory<ICiviCrmApi>("*")) { using (var channel = channelFactory.CreateChannel()) { var result1 = channel.ContactSave(ApiKey, SiteKey, customContact); Debug.Assert(result1.Id.HasValue); // Custom fields don't come by default for contacts. So we have to specify ReturnFields. var result2 = channel.GetSingle(ApiKey, SiteKey, CiviEntity.Contact, new IdRequest {Id = result1.Id.Value, ReturnFields = "custom_10,first_name,last_name"}) as JObject; Debug.Assert(result2 != null); var contact = result2.ToObject<CustomContact>(); Console.WriteLine("{0} {1} ({2})", contact.FirstName, contact.LastName, contact.GapId); } } }