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


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

Login to post a comment
JS Bin