RE-Decoded

A technical look at the Raiser’s Edge API from Blackbaud

Creating Attributes with the BatchAPI

July 3rd, 2008 by David Zeidman

Following my previous article on creating a batch with a notepad I am following it up with a some code that adds attributes. This is more or less shown on the Blackbus thread that I referenced but I wanted to clarify some of the steps having gone through the procedure myself.

Like the  example with the notepad you still need to add a reference to the “other” batch API. Unlike notepads however there are some steps you need to take in order to set the batch up correctly. In the notepad example you need to give the notepad type (in text) and the notes and reference the correct entries in the temporary object (CTempObject). With attributes it is somewhat more difficult.

Firstly you need to specify the attribute type. At first I thought this should be done in the same way as with the notepad type. However this is not the case. When you set up the batch you need to specify the attribute type id too. The code below shows how this is done.
Before you can call this you need to determine the attribute type id as follows:

Dim typesServer as New CAttributeTypeServer
typesServer.Init(SessionContext)
id = typeServer.GetAttributeTypeID("my attribute category", bbAttributeRecordTypes.bbAttributeRecordType_GIFT)
SetupBatchAttributeField(batchFields.Add(), EattributeFields.Attribute_fld_VALUE, id)
SetupBatchAttributeField(batchFields.Add(), EattributeFields.Attribute_fld_COMMENTS, id)
SetupBatchAttributeField(batchFields.Add(), EattributeFields.Attribute_fld_ATTRIBUTEDATE, id)

The batch set method is defined below:

Private Sub SetupBatchAttributeField(ByVal batchField As CBatchField, ByVal attField As EattributeFields, ByVal attId As Integer)
  With batchField
  .Fields(EBatchFieldFields.BatchField_fld_MetaObjectId) = bbMetaObjects.bbmoGIFT_ATTRIBUTE
  .Fields(EBatchFieldFields.BatchField_fld_FieldNumber) = attField
  .Fields(EBatchFieldFields.BatchField_fld_ObjectID) = attId
  End With
End Sub

There are many other ways that seem much more intuitive but from what I can gather this is the way you have to set up the batch. When you go into the batch you see that the column headers refer to the attribute you are adding (”my attribute category” in the above case).

Once you have set up your batch you add the values in the same way as the notepad - assigning them to the temp object directly. There is no need to assign the attribute type id in this way though as it was assigned during the batch set up.

When you then look at the batch you see that the attribute columns have headers like My attribute Category Description, My attribute Category Comment, My attribute Category Date, etc.

Related posts:

  1. Working with Attributes Attributes are a common tool within The Raiser's Edge. I...
  2. Using the Batch API with Notepads or Attributes I have started to use the Batch API in earnest...
  3. Battling on with the Batch API I have on several occasions expressed my delight about the...

Posted in Intermediate |

One Response

  1. API help with Gifts with Attribute - Blackbaud User Society - Forum Says:

    [...] me so a lot of thanks goes to Ivan for figuring it out. Here is the link if you are interested: RE-Decoded ? Blog Archive ? Creating Attributes with the BatchAPI David __________________ David Zeidman Zeidman Development http://www.zeidman.info Check out my [...]

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.