For version 7.7:

Public Sub AddRelationship()



   Dim oRec As CRecord

   Dim lID As Long

   Dim iRelation As CRecord

   Dim oInd As CIndividual2

   

   Set oRec = New CRecord

   oRec.Init REApplication.SessionContext

   'load Organization Record

   oRec.Load 565

   

   'create relationship

   Set iRelation = New CRecord

   With iRelation

       .Init REApplication.SessionContext

       .Fields(RECORDS_fld_IS_CONSTITUENT) = False

       .Fields(RECORDS_fld_LAST_NAME) = "Doe"

       .Fields(RECORDS_fld_FIRST_NAME) = "Jane"

       .Fields(RECORDS_fld_TITLE_1) = "Mrs."

       .Fields(RECORDS_fld_PRIMARY_ADDRESSEE_EDIT) = True

       .Fields(RECORDS_fld_PRIMARY_ADDRESSEE) = "Mrs. Jane Doe"

       .Fields(RECORDS_fld_PRIMARY_SALUTATION_EDIT) = True

       .Fields(RECORDS_fld_PRIMARY_SALUTATION) = "Jane Doe"

       .Save

       lID = iRelation.Fields(RECORDS_fld_ID)

       .CloseDown

   End With

   Set iRelation = Nothing

   

   'add Relationship to organization

   Set oInd = New CIndividual2

   oInd.Init REApplication.SessionContext

   With oInd

       .Fields(INDIVIDUAL2_fld_CONSTIT_ID) = oRec.Fields(RECORDS_fld_ID)

       .Fields(INDIVIDUAL2_fld_RELATION_ID) = lID

       .Fields(INDIVIDUAL2_fld_IS_CONTACT) = True

       .Fields(INDIVIDUAL2_fld_CONTACT_TYPE) = "Primary"

       .Save

       .Address.Links.BreakLink .Address.Fields(CONSTIT_ADDRESS_fld_ID)

       .Address.Fields(CONSTIT_ADDRESS_fld_ADDRESS_BLOCK) = "2000 Daniel Island Drive"

       .Address.Fields(CONSTIT_ADDRESS_fld_CITY) = "Charleston"

       .Address.Fields(CONSTIT_ADDRESS_fld_POST_CODE) = "29492"

       .Save

       .CloseDown

   End With

   Set oInd = Nothing

   oRec.Save

   oRec.CloseDown

   Set oRec = Nothing



End Sub

Disclaimer: We provide programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Microsoft Visual Basic and the tools used to create and debug procedures. Our Customer Support can help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality. If you are interested in learning more about the VBA and API modules, contact your account manager.