Start a new topic

Autofilling multiple action feilds

Good morning all!

 

I'm working on some code for an import where each record can have multiple actions (each action being different) and as each action is being added I need to add a completed date, category, date added, and date fields (that all vary depending on which action is being added). When I go to test my code it doesn't throw any errors but I can't get it to modify the data in the record to add the correct dates and modify the category.

 

I was wondering if I could acquire some assistance in figuring out why the records won't update with the information I need to have autofilled. I am new to API and RE in general (only been here for about a month and a half) so I'm sorry if I'm not as clear about what I'm trying to do. If you have questions let me know and I can try to explain myself a bit better.

 

Here's what I have so far:

 

Public Overrides Sub AfterConstituentOpen(ByVal oRec As CRecord, ByVal Cancel As iCancel)
   MyBase.AfterConstituentOpen(oRec, Cancel)
  Dim oAction As Blackbaud.PIA.RE7.BBREAPI.CAction
  Dim sConstitID as String =  1

For Each oAction In oRec.Actions
 
If (
 oAction .Fields(Blackbaud.PIA.RE7.BBREAPI.EActionFields.Action_fld_type).Value.Contains("Attended 2006 Gala 5-27-2006"))Then

                                                                                                   '^this is where I'm trying to find the event in the record

 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_COMPLETED_DATE).Value="05/27/2006"

                                                                                            '^this is where I'm trying to add this field and the ones below to the record given the event found.
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE).Value="05/27/2006"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE_ADDED).Value="05/27/2006"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_CATEGORY).Value="Task/Other"
ElseIf(
 oAction .Fields(Blackbaud.PIA.RE7.BBREAPI.EActionFields.Action_fld_type) = "Attended Animalerie 10-22-2004" )Then

 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_COMPLETED_DATE).Value = "10/22/2004"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE).Value = "10/22/2004"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE_ADDED).Value = "10/22/2004"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_CATEGORY).Value= "Task/Other"

ElseIf(
 oAction .Fields(Blackbaud.PIA.RE7.BBREAPI.EActionFields.Action_fld_type) = "Attended Big Bend 3-31-2011" )Then

 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_COMPLETED_DATE).Value = "03/31/2011"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE).Value = "03/31/2011"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE_ADDED).Value = "03/31/2011"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_CATEGORY).Value= "Task/Other"

ElseIf(
 oAction .Fields(Blackbaud.PIA.RE7.BBREAPI.EActionFields.Action_fld_type) = "Attended Bittersweet Harvest 2-25-2011") Then

 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_COMPLETED_DATE).Value = "02/25/2011"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE).Value = "02/25/2011"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE_ADDED).Value = "02/25/2011"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_CATEGORY).Value= "Task/Other"

ElseIf(
 oAction .Fields(Blackbaud.PIA.RE7.BBREAPI.EActionFields.Action_fld_type) = "Attended Buck Winn 12-7-2010" )Then

 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_COMPLETED_DATE).Value = "12/07/2010"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE).Value = "12/07/2010"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE_ADDED).Value = "12/07/2010"
 oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_CATEGORY).Value= "Task/Other"

 

End If

Next oAction
oAction = Nothing

 

End Sub

 

 

 

Thanks for all your help in advance!!!

-Matt

 


Wayne,

I actually got the code to work. I figured I'd post it if anyone else ever runs into similar issues.

Thank you for all your help along the way!

 

The only thing left that we were trying to modify was to add a solicitor, but when I tried to do that through API it told me that the Solicitor field is "Read Only" (which also explains why I don't see it in Global Change).

It's not that big of a deal to have, just would have been nice.

 

Imports Microsoft.VisualBasic
Imports System
Imports System.Linq
Imports Blackbaud.PIA.RE7.BBREAPI
Imports ImportOM.API

Public Overrides Sub BeforeConstituentSave(ByVal oRec As CRecord, ByVal Cancel As ImportOM.API.iCancel)
  ' oRec = New  .CRecord
   MyBase.AfterConstituentOpen(oRec, Cancel)
  Dim oAction As CAction
  Dim sConstitID as String =  1
msgbox("Constituent opened")
For Each oAction In oRec.Actions
msgbox("Action started")
 
If (
 oAction.Fields(EActionFields.Action_fld_type)= "Attended 2006 Gala 5-27-2006")Then
  msgbox("found attended event")                    ^changed formatting around a bit here
 oAction.Fields(EACTIONFields.ACTION_fld_COMPLETED)="True"

                                                        ^found out I needed to add "action completed" before I can add a "completed date"
 oAction.Fields(EACTIONFields.ACTION_fld_COMPLETED_DATE)="05/27/2006"
  msgbox("date completed modified")
 oAction.Fields(EACTIONFields.ACTION_fld_DATE)="05/27/2006"
  msgbox("date field modified")
 oAction.Fields(EACTIONFields.ACTION_fld_CATEGORY)="Task/Other"
  msgbox("action category modified")
 
 
ElseIf(
 oAction.Fields(EActionFields.Action_fld_type)= "Attended Animalerie 10-22-2004" )Then
  msgbox("Action found and modifying")
 oAction.Fields(EACTIONFields.ACTION_fld_COMPLETED)="True"
 oAction.Fields(EACTIONFields.ACTION_fld_COMPLETED_DATE)= "10/22/2004"
 oAction.Fields(EACTIONFields.ACTION_fld_DATE)= "10/22/2004"
 oAction.Fields(EACTIONFields.ACTION_fld_CATEGORY)= "Task/Other"
 
  msgbox("Action modified!")

.......

End If

oAction.Save

^added oAction.Save for good measure
Next oAction
oAction = Nothing

 End Sub  

 

Login or Signup to post a comment