Prior to the release of The Raiser’s Edge version 7.94 I was working with all of our products to ensure compatibility with this latest version. If you have not heard (and if you have not heard where have you been hiding), this release of RE removes phones and emails from physical addresses.
When the concept of emails was new, it was possible that you would have an email address tied to your telephone provider or an email address specific to your place of work. Your phone would either be at home or at work. Having these connnected to your physical address made sense. However it quickly became aparent that with the arrival of mobile phones and of email addresses that were accessible no matter where you were located, phones and emails (and for that matter all types of communication links) should be tied directly to the constituent record and not to a physical address. This is what has happened with the release of RE7.94.
This is a big shift and in terms of developing applications, we have had to allow for both possibilities so that our programs are compatible with users still on 7.93 and below and those that have made the leap over to 7.94.
The good news is that the old way of doing things still works in 7.94. You can still access phones via the CConstitAddress.Phones collection for an address. However you will probably want to access them how they are intended… Free from addresses.
This is done using the new interface IBBPhonesParent. This is implemented by CRecord, CIndividual2 and COrganization2. The collection of phones is a CConstitPhones object which contains the usual methods. You can iterate the collection to give you one CConstitPhone object but here is the problem.
For reasons that I don’t fully understand (I was told due to binary compatibility reasons) there are no properties or methods on the CConstitPhone object. Instead you have to convert this object to an IBBDataObject in order to access the Fields property. This is a real pain but to save myself some trouble I put together two extension methods for the CConstitPhone object which does this for me. (Unfortunately extension properties do not exist so that is why I cannot simply create an exact corresponding Fields properties. Those working with C# will be familiar with this as there is not a Fields property but rather get_Fields and set_Fields methods)
<System.Runtime.CompilerServices.Extension()> _ Public Function Fields(ByVal phone As CConstitPhone, fieldConstant As ECONSTITPHONEFIELDS) As Object Dim dataobject As IBBDataObject = CType(phone, IBBDataObject) Return dataobject.Fields(fieldConstant) End Function
<System.Runtime.CompilerServices.Extension()> _ Public Sub Fields(ByVal phone As CConstitPhone, fieldConstant As ECONSTITPHONEFIELDS, value As Object) Dim dataobject As IBBDataObject = CType(phone, IBBDataObject) dataobject.Fields(fieldConstant) = value End Sub
With these extension method you can simply access the Fields methods on a CConstitPhone object in almost the same way as you would with other objects.
So here is an example of creating a new phone on a constituent record using the above extension code.
Dim constit As CRecord = GetConstituent() Dim phonesParent As IBBPhonesParent Dim phones As CConstitPhones Dim phone As CConstitPhone phonesParent = CType(constit, IBBPhonesParent) phones = phonesParent.Phones phone = phones.Add() phone.Fields(ECONSTITPHONEFIELDS.CONSTIT_PHONES_fld_PHONETYPE, "Home") phone.Fields(ECONSTITPHONEFIELDS.CONSTIT_PHONES_fld_NUM, "123-4567") phone.Fields(ECONSTITPHONEFIELDS.CONSTIT_PHONES_fld_IS_PRIMARY, True) constit.Save() constit.CloseDown() constit = Nothing