Hi Steve
Yes AY, AZ and BA are mapped event ID.
I don't understand your 2nd question. The code is written in code editor (Launch code editor in virtual field). I don't have any procedure in which to have this code in.
I'm sorry if this is so stupid sounding. I'm new to this and not quite sure where I'm going wrong.
Thanks so much for helping me.
Felicia
Hi Stephen, I know it has been a long time but is there a way to confirm that your way of adding new participants to an event works? I have been trying it but I get a weird error fired up at the oParticipant.Save() step. Error reads: Can not call friend function on object which is not an instance of defining class.
Thanks in advance.
Jeton
Hi Jeton,
Can you paste your code here so I can take a look?
Thanks,
John
Hi John,
I found where my mistake was, I was doing it in the BeforeImportComputedColumns method, while in the example above it is AfterConstituentSave method. I do not know why it would not work there but when I moved, it worked all well.
For future reference, I am posting my code. Just fyi, in my case, constituent is not the same as event participant, but I need to link constituent's gift to a specific participant (could be same or different based on the context). I am storing fundraiser id in the import file:
Dim EventSystemID As Integer = Utils.getValFromArray(EventID, EventRecordsLength, EventRecords, 0, 2) 'get the event system ID based stored in an array
Dim oFundraiserRec As New CRecord 'fundraiser record (not donor itself necessarily)
Dim oEvent As New CSpecialEvent 'the event
oEvent.Init(Export.SessionContext)
oEvent.Load(EventSystemID)
oFundraiserRec.Init(Export.SessionContext)
oFundraiserRec.LoadByField(bbRecordUniqueFields.uf_Record_CONSTITUENT_ID, FundraiserConstID) 'load fundraiser based on their ID in the import file (stored in variable FundraiserConstID)
oPart.EventObject = oEvent 'attach the event to the participant
'link oFundraiserRec to participant and other relevant fields
With oPart
.Fields(EParticipantsFields.Participants_fld_KeyIndicator) = bbKeyIndicator.bbki_ORG
.Fields(EParticipantsFields.Participants_fld_RecordsID) = oFundraiserRec.Fields(ERECORDSFields.RECORDS_fld_ID)
.Fields(EParticipantsFields.Participants_fld_ConstituentID) = oFundraiserRec.Fields(ERECORDSFields.RECORDS_fld_CONSTITUENT_ID)
.Fields(EParticipantsFields.Participants_fld_EventID) = EventSystemID
.Fields(EParticipantsFields.Participants_fld_Attended) = true
.Fields(EParticipantsFields.Participants_fld_Registration) = "Registered"
.Fields(EParticipantsFields.Participants_fld_RegistrationDate) = DateTime.Now.ToString("MM/dd/yyyy")
End with
oPart.Save 'save participant
oFundraiserRec.CloseDown
oFundraiserRec = Nothing
oEvent.CloseDown
oEvent = Nothing
Felicia Nair
Hi
I'd like to be able to add multiple events from an event enquiry from on a constituent record. The code I wrote below does not work. No events are imported. The participant attributes are the same for all the constituents I'm new to coding and I'd be so grateful for any advice on my coding below.
If Import.Fields.GetByExcelName("R").Value.ToLower.Startswith ("x") THEN
Import.Fields.GetByExcelName("AY").Value = "SL2P17"
Microsoft.VisualBasic.MsgBox(Import.Fields.GetByExcelName("AY").Value.ToString)
End If
If Import.Fields.GetByExcelName("S").Value.ToLower.Startswith ("x") THEN
Import.Fields.GetByExcelName("AZ").Value = "SFBZ17"
Microsoft.VisualBasic.MsgBox(Import.Fields.GetByExcelName("AZ").Value.ToString)
End If
If Import.Fields.GetByExcelName("T").Value.ToLower.Startswith ("x") THEN
Import.Fields.GetByExcelName("BA").Value = "SFSTM17"
Microsoft.VisualBasic.MsgBox(Import.Fields.GetByExcelName("BA").Value.ToString)
End If
Thanks so much in advance.
Felicia