Public Sub RemoveOrgRelationships() Dim oRels As CRelationships2 Set oRels = New CRelationships2 'Load constituent record using system record id oRels.Init REApplication.SessionContext, 753 'Find the relationship to be removed and remove it Dim oRel As CRelationship2 For Each oRel In oRels If oRel.Fields(RELATIONSHIP_FLD_Type) = "Organization" Then Dim oOrg As COrganization2 Set oOrg = New COrganization2 With oOrg .Init REApplication.SessionContext .LoadByField uf_Organization2_IMPORT_ID, oRel.Fields(RELATIONSHIP_FLD_Import_Id) 'Loads the organization relationship Debug.Print "Removing " & oRel.Fields(RELATIONSHIP_FLD_Type) & " relationship to: " & .Fields(ORGANIZATION2_fld_NAME) 'setting to true will also remove reciprocal relationship .Delete True .Closedown End With End If oRel.Closedown Next oRel oRels.Closedown Set oRels = Nothing Set oRel = Nothing Set oOrg = 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.