I am hoping someone can point me in the right direction.
I would like to use the API to do a lookup to check if a constituent has an action record with a specific type. The purpose of this lookup is to prevent IOM from adding a second action of the same type if it is already present on the constituent.
Thank you in advance!
Thank you for your suggestion. I will look through your code and do some testing.
Your help is appreciated!
Thank you for following-up. Perhaps I should have given you more details before asking questions!
Your 'test' code passes a string value ("1") as the constituent ID. I added a constituent ID column to my file and referenced it (import.fields.getbyname) instead of "1" so that I could use some real examples in our database. However, I would like IOM to be able to match to an existing constituent (using its standard matching functionality) if an ID is not present in the file. Once it matches on a constituent, then do the Action lookup. The reason for this is the data files the profile will eventually process may only have bio info, but no ID.
Currently I have mapped some of the file's fields in the "front end" mapping section and the rest in virtual fields (the profile currently works). However, originally, I attempted to map everything using virtual fields (ie. "Action Type") and then reference them in the code as needed (Import.Fields.GetByName("Action Type").Value="XXX"). Other fields, such as an action attribute, had values in the data file ("Action Subtype") but I created a virtual field ("SubType") and referenced them in code instead of mapping the fields in the "front end" (ie. Import.Fields.GetByName("Subtype").Value=Import.Fields.GetByName("Action SubType").Value). I added an Else statement because if the first condition is not met (Action Type ="xxx" does not exist) then I wanted to add Action Type = "xxx" on the Constituent's record. This initial approach resulted in IOM adding the Action Type regardless of whether the first IF statement was true or false, I was only curious why.
Thank you for your response. If I place the code in the Public Override AfterConstituentOpen can I forego providing the Constituent ID (ie. by this point IOM will have matched on a record using its own match functionality)?
Thank you for the code, I have successfully tested it. This was immensely helpful!! I do have a couple of follow-up questions about your code sample, if you don't mind.
1. The code you provided requires the ConstitID to be provided in the import file, can the code be modified to pass the constituent ID of the record IOM matches during the matching process?
2. I got the code to work eventually, but my initial approach didn't. What I attempted to do, at first, was modify your code to include an else statement and map the data in code (I have put it in italics). Therefore, if the action type does exist the data should be ignored, otherwise IOM should import the data as a new record. For some reason (probably a mistake on my part!), IOM added the Action Type even though it already existed on the Constituent. Why?
'Lookup Action Type to find Vol-Volunteer Record
Dim oRec as New Blackbaud.PIA.RE7.BBREAPI.CRecord
Dim oAction as Blackbaud.PIA.RE7.BBREAPI.CAction
Dim sConstitID As String = Import.Fields.GetByName("Constituent ID").Value
For Each oAction In oRec.Actions
If oAction .Fields(Blackbaud.PIA.RE7.BBREAPI.EActionFields.ACTION_fld_TYPE)= "XXX" Then
'Set all Action Fields in the Import file to ""
Import.Fields.GetByName("Action Attr Desc 1").Value=""
Import.Fields.GetByName("Action Attr Desc 1").Value=Import.Fields.GetByName("YYY").Value
oAction = nothing
oRec = Nothing