Adding an email to a newly created constituent.

Options

 I'm working with the API with C#. So far I've been able to Create, Find, and Update records. However I'm running into some trouble trying to add an email address to a record. The API documentation mentions that the phone/email/links area is similar to the Attributes functionality. However it doesn't really give any good references.

 Can anyone point me in the right direction?

Comments

  • Verndale Verndale:

     I'm working with the API with C#. So far I've been able to Create, Find, and Update records. However I'm running into some trouble trying to add an email address to a record. The API documentation mentions that the phone/email/links area is similar to the Attributes functionality. However it doesn't really give any good references.

     Can anyone point me in the right direction?

    They are not exactly the same as attributes but they are similar. Firstly phones are associated with addresses (although we have been told that this is changing in RE 7.94 but I assume that this will be backward compatible). If you want to add a phone to a constituent you first have to add it to an existing address. You can use the preferredAddress property of the CRecord object to get hold of the preferred address. Using that CAddress object you can then get the Phones property and add to that. You do this by calling the following:

    phone = constit.PreferredAddress.Phones.Add

    Once you have your phone object you can set the fields on it just as you would with any other object.

    You have to save the constituent record in order for any of this to be saved to the database.

  • David Zeidman:

    They are not exactly the same as attributes but they are similar. Firstly phones are associated with addresses (although we have been told that this is changing in RE 7.94 but I assume that this will be backward compatible). If you want to add a phone to a constituent you first have to add it to an existing address. You can use the preferredAddress property of the CRecord object to get hold of the preferred address. Using that CAddress object you can then get the Phones property and add to that. You do this by calling the following:

    phone = constit.PreferredAddress.Phones.Add

    Once you have your phone object you can set the fields on it just as you would with any other object.

    You have to save the constituent record in order for any of this to be saved to the database.

     Thanks, you pointed me in the right direction. After looking at the Constituent screen again in RE it makes sense, only a little bit, that the Phone/Links/Email are apart of the Preferred Address.

     I did have one follow up question, whats the correct PhoneType Enum to use?

     Currently I am doing this.

    CConstitAddressPhone cConstitAddressPhone = record.PreferredAddress.Phones.Add();

                       

    cConstitAddressPhone.set_Fields(ECONSTIT_ADDRESS_PHONEFields.CONSTIT_ADDRESS_PHONES_fld_PHONETYPE, "Email");

    cConstitAddressPhone.set_Fields(ECONSTIT_ADDRESS_PHONEFields.CONSTIT_ADDRESS_PHONES_fld_NUM, email);

    In my brief searching I found and tried to use EST_PhoneType.staticentryPhoneTypeEmailAddress instead of hardcoding "Email", but that throws an exception about an invalid type when you try and save the record. Is there a define enum somewhere to use?

Categories