Start a new topic

Programmatically linking existing gifts to a participant

I have a very specific import support I need. I am trying to link existing gifts to specific participants of an Event. I was able to achieve this through mapping the Gift Import ID and Participant Import ID to their relevant fields as shown below:

 

image


 

This works perfectly. However, I need to do the exact same thing, but using the API code. SO far I have this:

 

        Dim oPart As New CParticipant

        oPart.Init(Export.SessionContext)

        oPart.Load(Import.Fields.GetByName("Participant System ID").Value)

       

        With oPart.Donations.Add

               .Fields(ELinkedGiftFields.LinkedGift_fld_LinkedGiftID) = Import.Fields.GetByName("Gift Import ID").Value

               .Fields(ELinkedGiftFields.LinkedGift_fld_GiftID) = Import.Fields.GetByName("Gift ID").Value 

        End with

               

        oPart.Save

        oPart.CloseDown

       

        oPart = nothing

 

But it is not working. Can this be achieved using the code?

1 Comment

Until the post got approved, I found the solution by experimeting. Anyways gonna post here in case someone needs it in the future:


You need to link the gift system ID instead of gift ID or Gift import ID. Just modified my code like this and it worked: 


With oPart.Donations.Add

        .Fields(ELinkedGiftFields.LinkedGift_fld_GiftID) =  Import.Fields.GetByName("Gift System ID").Value

End with

Login to post a comment