Public Sub AddAliasRelationship()

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 AAA Concrete

oRec.Load 751 'record in sample data

'create relationship record
Set iRelation = New CRecord

With iRelation
.Init REApplication.SessionContext
.Fields(RECORDS_fld_IS_CONSTITUENT) = False
.Fields(RECORDS_fld_LAST_NAME) = "Smith"
.Fields(RECORDS_fld_FIRST_NAME) = "John"
.Fields(RECORDS_fld_TITLE_1) = "Mr."
.Save

lID = iRelation.Fields(RECORDS_fld_ID)
.Closedown
End With

Set iRelation = Nothing

Dim lAddID As Long

'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"
.Aliases.Add.Fields(ALIAS_fld_ALIAS_TYPE) = "Stage Name"
.Aliases.Add.Fields(ALIAS_fld_KEY_NAME) = "Smithey"
.Save

'Breaks link with org. address and adds new address
.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"

'Adds phone number
With .Address.Phones.Add
.Fields(CONSTIT_ADDRESS_PHONES_fld_PHONETYPE) = "Home"
.Fields(CONSTIT_ADDRESS_PHONES_fld_NUM) = "8004688996"
oInd.Save
End With

.Save
.Closedown

End With

'Cleanup
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. Blackbaud Customer Support may help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality.