Start a new topic

New record vs. matched

How would I tell if the record I am looking at in the API (oRec in BeforeConstituentSave for example) is newly created by the import or if it was matched?

I would like to treat them differently.

1 person has this question

Great, glad you're making progress!  Yes, the MyBase line is needed.

Thanks John. That seemed to work.

I'm quite new to the API, still trying to work out some of the objects. Is the myBase line needed

  Public Overrides Sub AfterConstituentOpen(ByVal oRec As Blackbaud.PIA.RE7.BBREAPI.CRecord, _
  Cancel As ImportOM.API.iCancel)
  MyBase.AfterConstituentSave(oRec, Cancel)
  ' TW Remove Constituent Code data if existing
  If Convert.ToInt32(oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_ID)) > 1 Then

 Import.Fields.GetByExcelName("B").Value = ""

 Import.Fields.GetByExcelName("C").Value = ""

 End If

Actually thinking back on this I think the issue is where you are doing it (which is my fault).  You'd want it in After Constituent Open, not Before Constituent Save.

1 person likes this

Can you post your code here? 

I've tried your code John in "Before Constituent Save" but it doesn't appear to detect the existing constituents.

I'm trying to do a conditional Constituent Code addition depending on new/existing. Blanking the incoming columns doesn't appear to work in this instance.

Any suggestions much appreciated.

Hi Perry,

IOM will not error out if you blank out all 4 of the fields in code, but you would have to do it in Before Constituent Save because you wouldn't know if they were new or existing until that point.

Something like

If Convert.ToInt32(oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_ID)) > 1 Then

Import.Fields.GetByExcelName("N").Value = ""

Import.Fields.GetByExcelName("O").Value = ""

End If

Will IOM error out the record if all 4 of the fields used to create the relationship are blank? I'm wondering if I could put a step in "after dictionaries" that blanked out or null valued these fields.


I only want to add the relationship for new constituents.


So you want to set it to not add a relationship if it doesn't currently exist?

Thank you. I want to use this to keep from adding a relationship. Creating the relationship involves 3 virtual fields, one data file field, and 2 dictionaries. How do I code "ignore this"?

Thanks John! This did the trick. With a little testing I was able to confirm that the ID field for new records is in fact populated with -1.

Hi Chase,

Try this instead

If Convert.ToInt32(oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_ID)) < 1

The value isn't populated as null for new records it's populated with -1 (or it might be 0, I don't recall)



2 people like this

Hey guys, sorry to resurrect an old thread, but I'm wondering if anyone can share an example of Nic's suggested solution in use. I've tried to do this in a couple ways, such as:

If oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_ID) = ""


If oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDFields.RECORDS_fld_ID) = Nothing

without any luck. I'm working in the After Constituent Open Sub, but I've tried a couple without any success.

Thanks in advance!


So far I have not found anything I was doing through my excel pre-processing that I can't do with the API and I can do a lot more that I could never do before!

One way to do this is to check if the record has an ID yet.


1 person likes this
Login or Signup to post a comment