RE-Decoded

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


Feeds:

Batch API – error with tempRecords is nothing

March 11th, 2013 by David Zeidman

“Nothing :
Init method must be called before using this object.” My colleague was testing a new application that I have written for a client. Every so often she would tell me that this error message was appearing in the control report. Everything else appeared to work. Just what did this mean? It was one of those classic RE error messages that means nothing. When I started to debug the problem I saw the error quite soon. Again it was one of those Batch API idiosyncrasies that just needed to be dealt with.

I was creating several gifts in a batch. I was looping through the gifts and creating each one.

For Each donation In donations
    tempRecords = CType(batch.TempRecords, Blackbaud.PIA.RE7.BatchData.CTempRecords)
    PopulateOneGift(constitSysId, batch, tempRecords.Add, donation)
    tempRecords.Save()
 Next

The error occurred on the second iteration of the loop. Whenever the tempRecords.Add
was called the error was raised. This was strange because normally you get this kind of error when you have not initialized the object or done a Closedown on it. Anyway the solution to add one line before calling the Add:

For Each donation In donations
    tempRecords = CType(batch.TempRecords, Blackbaud.PIA.RE7.BatchData.CTempRecords)
    tempRecords.Reload()
    PopulateOneGift(constitSysId, batch, tempRecords.Add, donation)
    tempRecords.Save()
 Next

That seemed to fix the problem.

EDIT: or so I thought. It appears as though it worked once then failed after that. I have now resorted to saving and closing the batch after each iteration and then opening it up again at the beginning. Ah the joys of the batch API.

Posted in Intermediate | Comments Off

Raiser’s Edge Integration with REST webservice

January 5th, 2012 by David Zeidman

I have been working on a new version of RETweet which will be released soon. In that version we are allowing users to create constituents from Twitter users. The amount of information that you get from Twitter about the Tweet and the person that tweeted is very limited. The real name of the Twitter user – and it is not always a real name – is given in one field so it could include the first and last name (this is the most common where it is not a Tweeting business).  To make this more useful the application reaches out to a webservice to determine the gender of the person.

The webservice takes the first name and returns gender information and which countries the name appears in. The web service is biased towards European and Western first names but does claim to cover some countries in Asia too.

This could also easily be integrated as a VBA solution so that when you save and close a constituent record, if the gender is unknown the VBA code reaches out to the webservice and populates the code. Here is some sample code that shows you how this is done. This is done using .NET as it is considerably easier to achieve than in the native VBA environment. It would, however, be easy to make a call to a COM visible assembly from the native VBA client to call this method.

 

' Determines the gender of the person by looking up useing Thomas Bayer's webservice.
Private Sub SetGender(firstName As String, constit as CRecord) 

   Dim xdoc As XDocument
   Try
      'Here we retrieve the XML document from the REST web service
      xdoc = sendXML("http://www.thomas-bayer.com/restnames/name.groovy?name=" & firstName)

      Dim result = xdoc.<restnames>

      'if there is an error then the gender cannot be found
      If result.Descendants("error").Count > 0 Then
         Return
      End If

      'This is not an ideal check as a name can be both male and female
      'but for simplicity we assume this is not the case
      If resultresult.<nameinfo>.<male>.FirstOrDefault.Value.ToLower = "true" Then
         constit.Fields(ERECORDSFields.RECORDS_fld_GENDER) = "male"
      Else
         constit.Fields(ERECORDSFields.RECORDS_fld_GENDER) = "female"
      End If
      Catch
         'If there is an error due to the web service we catch it here and don't bother the end user.
      End Try

End Sub

Private Function sendXML(ByVal uri As String) As XDocument

   Dim request As HttpWebRequest
   Dim response As HttpWebResponse
   Dim reader As XmlReader

   request = HttpWebRequest.Create(uri)
   response = request.GetResponse()

   reader = XmlReader.Create(response.GetResponseStream())
   Return XDocument.Load(reader)

End Function

 

Look out for our new version of RETweet. It will include this and a lot of other new features!

Posted in Intermediate | Comments Off

A .NET Fix

August 13th, 2011 by David Zeidman

This post is totally unrelated to The Raiser’s Edge and the API but in case others are having the same issue I wanted to describe how I fixed it. I have just spent the last several hours trying to get the progress bar to scroll in the marquee style. I had seen several posts referring to using a background worker to retrieve data from the database while the progress bar scrolled in the UI thread. It sounded like the right solution but it didn’t make a difference.

I read one post that helped. It said that before you instantiate your form you need to enable the visual styles.

Application.EnableVisualStyles()

When I ran my application all of a sudden not only was my progress bar scrolling nicely but all of a sudden I could see the graphical styles that I always had seen in Visual Studio but never experienced in my Winform applications.

Posted in Intermediate | Comments Off

The Problem with Quick Find

June 11th, 2010 by David Zeidman

I have been working on a new product which will hopefully be released soon. In this new product the user needs to be able to look up a constituent in as few key strokes as possible. The approach that I took was to use the same functionality as the Quick Find mechanism that you see on the records page in The Raiser’s Edge. This is dependant on your user settings so that you can either put in a constituent id, the first name followed by the surname or the surname comma the first name. While I was testing it on the sample database it worked perfectly. However when I tested it on a client’s very large database there were issues. Read the rest of this entry »

Posted in Intermediate | Comments Off

Looking up a constituent

May 4th, 2010 by David Zeidman

Whenever I write a bespoke customisation for a client that needs to look up a constituent based on some biographical information I normally use the functionality available behind the scenes in IDLookup. If you are unfamiliar with IDLookup, it allows users to feed in an Excel or CSV file of names, addresses, aliases, attributes and all sorts of biographical information. Then based on criteria that you define, it will look to see if one or more constituents already exist in The Raiser’s Edge. I use much of the look-up functionality in other projects simply because Blackbaud chose not to make this functionality easily available. There is no back-end interface to their regular constituent look-up screen which is a real shame. The nearest feature is the IBBRecordFinder interface.

Read the rest of this entry »

Posted in Intermediate | 4 Comments »

Writing Code to populate the rejection code field in batch

November 11th, 2009 by David Zeidman

Sorry to get your hopes up but I am reliably informed that you cannot do this. And the reason? “PCI Compliance”. Read the rest of this entry »

Posted in Intermediate | 4 Comments »

C# API Try Catch Finally Snippet

October 6th, 2009 by David Zeidman

I have been doing some work with C# recently and  decided that despite what people say C# is as equally verbose as VB.NET. It is true if you look at the number of characters in a VB program compared to the equivalent C# program there will be a greater number but you seem to get a lot more automatic inserts with VB than you do with C#. C# seems to have a lot more punctuation that VB too adding up to a lot more typing than I was used to.

Read the rest of this entry »

Posted in Intermediate | Comments Off

Recurring Gift Schedules

August 5th, 2009 by David Zeidman

One of the harder imports that you may have to do in The Raiser’s Edge is importing recurring gifts with schedules. The regular help file itself suggests itself that it is tricky but then unfortunately does not offer any examples. Writing code to create various schedules is equally as difficult if not harder.  This post does apply to pledges with schedules but, here in the UK, recurring gifts are much more common than pledges with schedules so I will concentrate on that but the same principles apply. I have also noticed that there are more and more people developing in C# so this is for them (but is not that hard to translate to VB.NET) Read the rest of this entry »

Posted in Intermediate | Comments Off

When Loading All Does not Load a Constituent

April 20th, 2009 by David Zeidman

I wrote a recent customisation where I needed to start with an empty database with no constituents and put in a subset of records from my client’s database. I took the sample database and globally deleted all records. So far so good.

Some code that I had written ages ago was going to be a part of this customisation and I ran it as part of a larger piece. The code would load all constituents (OK I forgot that I did not have any) and select the first one. This is a really simple task but I got some strange results.

Read the rest of this entry »

Posted in Intermediate | Comments Off

Installing a .NET plugin revisited

January 19th, 2009 by David Zeidman

A while back I wrote a post about how to install a .NET plugin. Since writing that post I now almost always use Windows installer to install my plugins but every so often they do not install I have not been able to work out why. Today though I think I cracked it.

Read the rest of this entry »

Posted in Intermediate, Not Code | 2 Comments »

« Previous Entries

Switch to our mobile site