Start a new topic

Existing Constituent Attributes (Add only when does not exist)

Hi,

I was trying to detect the existing Cons Unique Attributes whether the "Program Contact Stream" Attributes is exist or not. I just want to add the Cons Unique Attributes (Program Contact Stream = Major Gift) only when it is not currently exist.

I apply the API code under AfterConstituentOpen.

But when I check the strProgramContactStream in MsgBox it is empty.

What did I do wrong? Please advise.

I also attached the Updates Constituent Attributes settings.


Thanks

Hendrik



Here is the API code:


  Dim strMailFrequency As String = ""

  Dim strMailFrequencyDate As Date

  Dim strMailFrequencyComments As String = ""

  Dim strReassignedID As String = ""

  Dim strProgramContactStream As String

  Dim strProgramContactStreamDate As Date

  Dim strProgramContactStreamComments As String

  For Each oAttr In oRec.Attributes

   lAttrTypeID = oAttr.Fields(EattributeFields.Attribute_fld_ATTRIBUTETYPES_ID)

   'MsgBox("Attribute Type: " & oAttrTypeServer.GetAttributeTypeDescription(lAttrTypeID) & VbCrLf & _

   ' "Attribute Description: " & oAttr.Fields(EattributeFields.Attribute_fld_VALUE),,"Constituent Attribute")

   Select Case oAttrTypeServer.GetAttributeTypeDescription(lAttrTypeID)

    'Case "Marked for Deletion"

    ' strMarkedForDeletion = oAttr.Fields(EattributeFields.Attribute_fld_VALUE)

    Case "Program Contact Stream"

     strProgramContactStream = oAttr.Fields(EattributeFields.Attribute_fld_VALUE)

     strProgramContactStreamDate = oAttr.Fields(EattributeFields.Attribute_fld_ATTRIBUTEDATE)

     strProgramContactStreamComments = oAttr.Fields(EattributeFields.Attribute_fld_COMMENTS)

     'MsgBox("Program Contact Stream" & VbCrLf & "Description: " & strProgramContactStream & VbCrLf & "Date: " & CStr(strProgramContactStreamDate) & VbCrLf & "Comments: " & strProgramContactStreamComments,,"Program Contact Stream")

    Case "Mail Frequency"

     strMailFrequency = oAttr.Fields(EattributeFields.Attribute_fld_VALUE)

     strMailFrequencyDate = oAttr.Fields(EattributeFields.Attribute_fld_ATTRIBUTEDATE)

     strMailFrequencyComments = oAttr.Fields(EattributeFields.Attribute_fld_COMMENTS)

     'MsgBox("Mail Frequency" & VbCrLf & "Description: " & strMailFrequency & VbCrLf & "Date: " & CStr(strMailFrequencyDate) & VbCrLf & "Comments: " & strMailFrequencyComments,,"Mail Frequency")

     Exit For

   End Select

  Next oAttr

  oAttr = Nothing




 If oGifts.Count > 0 Then 'cash gifts within past 24 months of gift date

           If .GetByName("Fund_ID").Value = "" Then

            .GetByName("Fund_ID").Value = "4010-100"

           End If

           If .GetByName("Campaign_ID").Value = "" Then

            .GetByName("Campaign_ID").Value = "DC"

           ElseIf (.GetByName("Campaign_ID").Value = "MG") And InStr(strProgramContactStream, "Major Gift") > 0)) Then

                      .GetByName("ProgramContactStreamCat").Value = ""

                   .GetByName("ProgramContactStreamDesc").Value = ""

                  .GetByName("ProgramContactStreamDate").Value = ""

                  .GetByName("ProgramContactStreamComment").Value = ""

                   MsgBox (strProgramContactStream)

                    Else

                      .GetByName("ProgramContactStreamCat").Value = "Program Contact Stream"

                   .GetByName("ProgramContactStreamDesc").Value = "Major Gift"

                   .GetByName("ProgramContactStreamDate").Value = Today()

                   .GetByName("ProgramContactStreamComment").Value = Import.ApplyDictionary("User Initials", .GetByName("User10").Value)

                 End If

Login or Signup to post a comment