One of the most useful collection of methods available to users of the API is IBBUtilityCode. This is an interface which means that it cannot be created by itself but is implemented by another class. That other class is REServices which itself contains many useful functions.
Once you have created an instance of the REServices class, like almost every other class you create, you need to initialise it. You can then do an explicit or an implicit conversion to the IBBUtilityCode class as below:
Dim reserv As New REServices
Dim utilCode As IBBUtilityCode
utilCode = CType(reserv, IBBUtilityCode)
Once you have an instance of IBBUtilityCode you can start using it. There are very many methods of use. Here follows some of the methods that I use more often.
Sometimes rather than loading a constituent yourself and having to close it safely down when all you need is their name then this method is perfect. You need to supply the system id, name and key indicator by reference. These then populated with their respective values. You can also optionally supply the first, middle and last names by reference too.
If you have a gift system id, rather than loading up the gift object itself you can simply call this method and get the constituent system id.
Whenever a record is saved or modified an id is stored on the record. However that id is simply a number and nothing that you would wanted to show the end user. This method allows you to supply the numeric id and get the user name of the user.
As a third party developer I have to write for different organisations that have different configurations. Some organisations have optional modules others do not. Some organisations are based in different countries and will have different fields present. In the UK there is the GiftAid section of the constituent reocrd. This is not seen by organisations in other areas and organisations in those countries do not need to interact with those fields. By using this method it is possible to determine whether or not the installation is a UK version of RE.
There are very many other methods that you should explore. Quite often one of the short cut operations that you need can be found here and it is well worth looking at.
Do you have a favourite method that you use in this interface or any other? Let us know in the comments
1 thought on “The Bag of Tricks that is IBBUtilityCode”
I have a separate class where I put IBBUtilityCode functions. It currently has (in addition to those listed):
DetermineAge (provide a fuzzy date to calculate age).
GetQueryName (provide the query ID).
I’d like to implement more as I can see how they’d save some coding (wish I’d have found IBBUtilityCode years ago).
Comments are closed.