Lookup by constituent system id – a new free plugin

There was a post on Blackbus recently where a Raiser’s Edge user was having trouble mapping the output of a third party system to RE. The other system had the constituent system id and did not have the import id or the constituent ids so importing the data directly into RE was proving to be a problem. It would also be difficult to do any kind of lookup natively in RE unless it was done manually through a query.

I suggested that this was a straight forward solution if you were to write a plugin. In fact I felt that it was so straight forward that I would just write it. So here it is a new plugin that takes a system constituent id and outputs the constituent and import ids appending them to a copy of the input file.

The crux of the code is a straight forward few lines:

   Private Sub LookupConstituent(ByVal oneRow As List(Of String), ByVal sysIdIndex As Integer)

        Dim constit As CRecord
        Dim sysId As Integer

        If Integer.TryParse(oneRow.Item(sysIdIndex), sysId) = False Then
            Throw New Exception("The system id (" & oneRow(sysIdIndex) & ") in the file is not a valid value")
        End If

            constit = New CRecord

            oneRow.Insert(0, constit.Fields(ERECORDSFields.RECORDS_fld_IMPORT_ID))
            oneRow.Insert(0, constit.Fields(ERECORDSFields.RECORDS_fld_CONSTITUENT_ID))

        Catch ex As Exception
            Throw New Exception("The system id (" & sysId & ") in the file cannot be found in Raiser's Edge")

            If constit IsNot Nothing Then
                constit = Nothing
            End If
        End Try

    End Sub

Before reaching this function the code takes a row from the file and splits it up into a list object. It then passes the row and the index of the system id into the function

The function then retrieves the system id checking that it is a valid integer, tries to load the constituent based on this value and if successful inserts the import id and constituent id into the the list. Coming out of the function the code would need to write this list back into the file.