The following snip-it of code demonstrates how to delete a specific attribute on a constituent's record. The code can be adjusted for any attribute type and for any attribute.




Public Sub DeleteAttribute()
Dim oRec As CRecord
Set oRec = New CRecord

Dim lattID As Long

Dim oAttribute As IBBAttribute

Dim REservices As REservices
Set REservices = New REservices
REservices.Init REApplication.SessionContext

Dim oAttributeServer As CAttributeTypeServer
Set oAttributeServer = REservices.CreateServiceObject(bbsoAttributeTypeServer)
oAttributeServer.Init REApplication.SessionContext

lattID = oAttributeServer.GetAttributeTypeID("Committees", bbAttributeRecordType_CONSTITUENT) 'Get the attribute ID

With oRec
.Init REApplication.SessionContext
.Load 280
For Each oAttribute In .Attributes 'Loop through the attributes to find the one you want to delete
If oAttribute.Fields(Attribute_fld_ATTRIBUTETYPES_ID) = lattID Then
.Attributes.Remove oAttribute 'Delete the attribute
End If
Next
.Save
End With
oRec.CloseDown
Set oRec = Nothing

REservices.CloseDown
Set REservices = Nothing

Set oAttributeServer = 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.