Using the Batch API with Notepads or Attributes

I have started to use the Batch API in earnest now. I have said previously that it is a great long overdue piece of functionality but I am beginning to understand why it was never included earlier. As with much of the API the newly added Batch API is not well documented. A good example of how to use it was given and can be found on Blackbaud’s knowledgbase (BB418575) but it is somewhat limited. It does not explain for example how to add an attribute or a notepad to a gift batch. This was discussed on a Blackbus thread.  Adding the items to the batch header was quite straight forward but adding the actual values proved more difficult. Here I try to shed some light on the process.

When you create a CTempObject from the collection of CTempObjects you are actually creating a row in the batch. When you have created the batch you notice that there is already a CTempObject in the collection. This I believe is the defaults header row which you can manipulate. Using the example code from Blackbaud and the Blackbus thread you can populate your gift which is then assigned to the temp object. However you cannot simply add attributes or notepads to the gift object and expect them to appear in your batch. Instead you have to add them to the temp object directly.

The following code shows how the temp object is constructed:

For i As Integer = 1 To 20


      Debug.Print(tempRecords.Item(2).FieldAttrib(i).sFieldname & " - " & _

                      tempRecords.Item(2).FieldNumber(i) & _

                      "," & i & " = " & tempRecords.Item(2).Fields(i))

   Catch ex As Exception

   End Try


I chose 20 as an arbitrary number. If you have added more fields to your batch then you will need a larger number. Equally if you have fewer fields then there will be an exception.

The results are give as follows:

Constituent Name – 22,1 = Zeidman, David
Amount – 4,2 = 1
Fund – 14,3 = GENFUND
Campaign – 13,4 = AnCampaign
Appeal – 15,5 = Spring Mailing
Date – 34,6 = 02/05/2008
NL post date – 50,7 = 02/05/2008
NL post status – 51,8 = Not Posted
Credit Type – 26,9 = Visa
Authorisation code – 9,10 = 123
Pay method – 49,11 = Credit Card
Gift notes Type0 – 2,12 =
Gift notes Notes0 – 15,13 =

As you can see the notes fields are blank. The first number refers to the gift field value (except for the notes where it refers to the notepad fields). The second number refers to the field or position in the temp record (or batch). To add the values to notes you simply assign the notepad type id and notes directly to the temp record:

oTempRecord.Fields(12) = "My note type"
oTempRecord.Fields(13) = "This is the contents of the note"

Normally this should work. However it does not and it creates an exception. This I am told is bug that the product development team at Blackbaud are aware of. However there is a workaround as is highlighted in the Blackbus post. Add a reference to BatchData and to BBInterfaces (by default found in C:\Program Files\Blackbaud\The Raisers Edge 7\PIA under Blackbaud.PIA.RE7.BatchData.dll and Blackbaud.PIA.RE7.BBInterfaces.dll). There are now two objects of the same name but different namespaces so that you have to ensure that import the correct namespace into the project otherwise you will use the objects that come with the BBREAP assembly. .In VB6 add references to Blackbaud RE Batch Objects 7.5 in the references list and ensure that it appears above the Blackbaud Raisers Edge 7 Objects reference.

Note that if you try to do this for the gift values (as I thought would be a better idea as you could just skip the whole gift creation thing) then an access exception is raised.

One thought on “Using the Batch API with Notepads or Attributes

Comments are closed.