Start a new topic

Exception file if a participant is already registered for an event

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


Appreciate the forebearance Nick - just to be clear the result I needed in this case (which is probably a different import to the one Gemma was working with) was:


* New registrant – carry on

· Existing registrant - exception


The new code you provided seems to have done the trick. Many thanks!

Hi Miles

 

It’s really not clear what you’re trying to achieve here.

 

Gemma first said: I need an exception file to be generated if they are already registered for the event.

·         New registrant – carry on

·         Existing registrant - exception

 

Then Gemma said: 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....

·         New registrant – exception

·         Existing registrant – carry on

 

You said: The profile needs to add people as Participants on a particular event (with status Enquired), unless they are already registered on the event (with any Status) in which case it should just skip the row. 

·         New registrant – carry on

·         Existing registrant - exception

 

 

John Shepard proposed what looks like a good solution, but what you’ve ended up with has been modified incorrectly so it wouldn’t work. It’s ended up comparing the name in the import file to the name of the supporter, whilst the original code compared the name of the supporter to the name of the participant(s).

 

I suggest all this section

 

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.GetByName("Which location would you be most interested in?").Value)

 

  For Each p As Blackbaud.PIA.RE7.BBREAPI.CParticipant In oEvent.Participants

  If import.Fields.GetByName("First name").Value =

  oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_FIRST_NAME) _

  AndAlso import.Fields.GetByName("Last name").Value =

  oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_LAST_NAME) Then

  Cancel.CancelRow("Already registered for the event")

  End If

  Exit For

  p=Nothing

  Next

Can be removed, if you use a version of the code I proposed – you’ll need to remove one of the cancelrows depending on whether you want exceptions for new or existing participants.:


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

     'must be a new registrant

Cancel.cancelrow("wasn't previously registered for the event")

     Else

          'must be an existing registrant

Cancel.cancelrow("was already registered for the event")

End if

 End Sub


Hope that helps

Nick

 

 

Hello,


I'm actually Gemma's successor at Battersea! I'm getting to grips with Omatic but still have a few gaps to fill in.


I have a profile that contains the code above (possibly added by Gemma), but it's not having the desired effect. The profile needs to add people as Participants on a particular event (with status Enquired), unless they are already registered on the event (with any Status) in which case it should just skip the row. 


The code and the sub it lives in are as follows:

  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.GetByName("Which location would you be most interested in?").Value)

 

  For Each p As Blackbaud.PIA.RE7.BBREAPI.CParticipant In oEvent.Participants

  If import.Fields.GetByName("First name").Value =

  oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_FIRST_NAME) _

  AndAlso import.Fields.GetByName("Last name").Value =

  oRec.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_LAST_NAME) Then

  Cancel.CancelRow("Already registered for the event")

  End If

  Exit For

  p=Nothing

  Next

  End Sub


I believe the intended effect of the code is 'check if the person (matching by first name and surname) is already on the event and if so skip the row'.

 

The trouble is, it's sending them to skipped rows even if the person is *not* in fact already registered for the event, and even if the person has not yet been created as a constituent. My guess, then, is that it's running this check after it's already added the person as a participant on the event.


Is the code actually needed to achieve the dupe-checking effect, or can that be achieved just in the profile settings? If it is needed, should I tweak it, or move it to a different part of the profile code?


Many thanks in advance,

Miles Potter

Thank you so much for this Nick! I is working beautifully!

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

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 John


Thank you so much for this! I shall give it a go!


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


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

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

Login or Signup to post a comment