HI Gemma,
Does your import file have a constituent or import ID in it? If not your only option would be to loop through each participant and see if the certain fields match to what's in the import file (I'd probably use first/last name and address). Let me know one way or the other and I can at least point you in the right direction.
Thanks,
John
Hi John
No import or Cons ID, I'm afraid. To add another layer of complexity, the supporter could be added into a number of different events depending on the year they have put in a date field. So if a supporter puts 02/05/18, they will be added to DYOT1800, if they put 09/12/19 they will be added to DYOT1900. If a supporter is signed up to DYOT1800, but they indicate in the date field DYOT1900, we are happy for them to be added to DYOT1900, rather than creating an exception.
All this being said, the volumes at the moment are expected to be very low, I am just trying to future proof to some extent.
Many thanks
Gemma
This is completely untested and just off the top of my head, but it should get you started
Public Overrides Sub BeforeConstituentSave(oRec As CRecord, Cancel As iCancel)
MyBase.BeforeConstituentSave(oRec, Cancel)
Dim oEvent As CSpecialEvent = New CSpecialEvent
oEvent.Init(Import.SessionContext)
oEvent.LoadByField(bbEventUniqueFields.uf_Event_EventID, eventIDgoesHere)
For Each p As CParticipant In oEvent.Participants
If p.Fields(EParticipantsFields.Participants_fld_FirstName) = oRec.Fields(ERECORDSFields.RECORDS_fld_FIRST_NAME) _
AndAlso p.Fields(EParticipantsFields.Participants_fld_LastName) = oRec.Fields(ERECORDSFields.RECORDS_fld_LAST_NAME) _
AndAlso p.Fields(EParticipantsFields.Participants_fld_AddressID) = oRec.PreferredAddress.Fields(ECONSTIT_ADDRESSFields.CONSTIT_ADDRESS_fld_ADDRESS_ID) Then
'Todo insert code to closedown event or point to a sub to close down
Cancel.CancelRow("Participant is already registered")
End If
p = Nothing
Next
'Todo insert code to closedown event or point to a sub to close down
End Sub
Hi John
Thank you so much for this! I shall give it a go!
Gemma
Hi John
It has taken a while for me to pick this up....due to a change in the way we are processing, I need to get the code to send anyone not already registered to an event ID in the file to an exceptions file, and if they are added to add attributes....
So a person is in my file as attending London Marathon 2020, and RE has a participation record for this constituent for London Marathon 2020, so two participation attributes can be added - all good!
If the person says London Marathon 2020 in the file, but does not have a participation record of London Marathon 2020 on their record, then I need an exception file generated...
I have this 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
MyBase.BeforeConstituentSave(oRec,Cancel)
Dim oEvent As Blackbaud.PIA.RE7.BBREAPI.CSpecialEvent = New Blackbaud.PIA.RE7.BBREAPI.CSpecialEvent()
oEvent.Init(Import.SessionContext)
oEvent.LoadByField(Blackbaud.PIA.RE7.BBREAPI.bbEventUniqueFields.uf_Event_EventID,import.Fields.GetByExcelName("BM").Value)
For Each p As Blackbaud.PIA.RE7.BBREAPI.CParticipant In oEvent.Participants
If import.Fields.GetByExcelName("C").Value <>
oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_FIRST_NAME) _
AndAlso import.Fields.GetByExcelName("D").Value <>
oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_LAST_NAME) Then
Cancel.CancelRow("Event ID should be Holding Event")
End If
Exit For
p=Nothing
Next
End Sub
But it isn't working. It is still adding the person to the Event if it doesn't already exist.
It's a little bit frustrating!
Thanks
Gemma
Hi Gemma
Another approach would be to process the participation attributes, but before saving the participation check whether it is brand new (added by IOM) or already existed. If it’s brand new, it won’t have an ID yet. That would look a bit like this:
Public Overrides Sub BeforeParticipantSave(ByVal oPart As Blackbaud.PIA.RE7.BBREAPI.CParticipant, _
ByVal oRec As Blackbaud.PIA.RE7.BBREAPI.CRecord, _
Cancel as ImportOM.API.iCancel)
If Convert.ToInt32(oPart.Fields(Blackbaud.PIA.RE7.BBREAPI. EParticipantsFields.Participants_fld_ID)) < 1 Then
Cancel.cancelrow("wasn’t previously registered for the event")
End if
End Sub
(credit to John Shephard from another thread about new records, which I can't find right now)
Give that a try….
Nick
Thank you so much for this Nick! I is working beautifully!
Gemma Pearce
Hi All
We have an event set up where constituents may be added manually or imported. The events are set up to only allow one registration. I need an exception file to be generated if they are already registered for the event. Having contacted support they have said it can only be handled through API. I am not great at this bit, so wondered if anyone had anything similar already?
Many thanks
Gemma