Start a new topic

Interacting with Declarations though the API/code

I'm trying to build some code to interact with Gift Aid Declarations, be able  to deal with when two would have an identical start date, etc. To do that, based on other code we use at my organisaton, I'm wanting to first make sure I can find the gift aid declarations on a record, go through them one by one.


It'd be a lot easier if it was possible to output a Gift Aid Declaration's Import ID in a query, so I could put that out and load the specific ones I'm after, but that appears to be impossible.


So, having seen Aliases on a record cycled through by code we used elsewhere, I'm wondering if I can do that with tax declarations. However, they seem rather more complicated.


As a 'proof of concept' I'm trying to save the number of tax declarations on a text record as a Constituent Notepad Notes on that record - the idea being if I can do that, the rest (hopefully) follows on. But I keep on getting "Object reference not set to an instance of an object." 


I suspect  the difference between this and the Alias coding I've come from is that BeforeConstituentSave is already looking at the 'right' Record object, and the alias code just needs to get it to look through the Aliases on that Record. Whereas Declarations are more complicated - I may have  created my Tax Declaration and Declarations objects correctly, but I'm failing to 'point' them at the record I'm dealing with. Is that the problem? If so, how do I point it at said record? And any other suggestions people might have.


My current code:


    Public Overrides Sub BeforeConstituentSave(ByVal oRec As Blackbaud.PIA.RE7.BBREAPI.CRecord, _

                                          Cancel as ImportOM.API.iCancel)

        'The main constituent record is about to be saved

        Dim oTax As Blackbaud.PIA.RE7.BBREAPI.CTaxDeclaration

        Dim oTaxes As Blackbaud.PIA.RE7.BBREAPI.CTaxDeclarations

       Dim TaxCount As Short = oTaxes.Count

 Import.Fields.GetByName("Count of Gift Aid Declarations").Value = "No. of Tax declarations" & TaxCount

    End Sub


Thanks!

1 Comment

I'm shortly going to be embarking on a major project to modify declaration records, so I'll be interested to know if you've made any progress.


There is the KB article on Blackbaud's site which looks like it will help us both:
https://www.kb.blackbaud.co.uk/articles/Article/48646

Login or Signup to post a comment