Start a new topic

Individual Relationships


What's the difference between CIndividual and CIndividual2?  I'm trying to add an Individual Relationship.



CIndividual2 is what you want to be using. CIndividual is an older interface that I believe it only used in internal collections now.
Thnaks Wayne.

I'm not even sure what I want to do is possible. We have a file with the Child's ID, Parent1 info and Parent2 info (may have parent2 - may not). Parent1 ID is the primary ID. We make a relationship between Parent1 and the child. We also add the spouse if needed. What we are now trying to do is add a relationship between the spouse and the child if the spouse happens to be a full constituent already. Currently, we do this in two separate imports and manipulate the mappings - making Parent2 the primary ID and creating a relationship if Parent2 is a full constit.

When I use the BeforeConstituentRelationshipSave sub i get the child relationship but when I try to add the relationship to parent2 i get the following error:
Cannot create an individual relationship using an organization.

Here's the code I'm using:
Public Overrides Sub BeforeIndividualRelationshipSave(ByVal oInd As CIndividual2, ByVal oIndRecord As CRecord, ByVal GroupNumber As Integer, ByVal Cancel As ImportOM.API.iCancel)
MyBase.BeforeIndividualRelationshipSave(oInd, oIndRecord, GroupNumber, Cancel)

Dim oChildID As Long
Dim oParent2 As Long

oChildID = import.Fields.GetByExcelName ("A").Value
oParent2 = import.Fields.GetByExcelName ("Q").Value

With oInd
.Fields(Blackbaud.PIA.RE7.BBREAPI.EINDIVIDUAL2Fields.INDIVIDUAL2_fld_DATE_FROM) = Date.Today
End With

End Sub

If you already have the IDs of the spouse and the child then you can create the relationship any time you want in the process so I would do it AfterSave or something.

You will need to create a New CIndividual2 record and populate it with the correct ids and then save it.

I would avoid the BeforeIndividualRelationshipSave function unless you are actually modifying the relationship that IOM is creating (which is not the case here).

Also note that BeforeIndividualRelationshipSave is potentially being called twice since you are making two different individual relationships through IOM (parent1/child and parent1/parent2 (spouse))
Thanks Wayne. I'll try it that way.
I got it to work.

Here's my code in case someone else is trying to do something similar:

Public Overrides Sub BeforeRowCommit(ByVal Cancel As ImportOM.API.iCancel)

'Now let's add a Parent/Child relationship to the spouse record (parent2) if they are a full constituent

Dim oChild As New CRecord 'new crecord for child
Dim oParent2 As New CRecord ' new crecord for parent2
Dim oChildID As Integer = 0
Dim oParent2ID As Integer = 0
Dim oInd As New CIndividual2 'new individual relationship record


oChild.LoadByField(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_CONSTITUENT_ID, Import.Fields.GetByExcelName("A").value)
oChildID = oChild.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_ID)

oParent2.LoadByField(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_CONSTITUENT_ID, Import.Fields.GetByExcelName ("Q").value)
oParent2ID = oParent2.Fields(Blackbaud.PIA.RE7.BBREAPI.ERECORDSFields.RECORDS_fld_ID)

With oInd
End With


End Sub

Thanks for your help.


1 person likes this
Nice work Lisa!
Login or Signup to post a comment