Start a new topic

Picking the right Action for Attributes

Good morning,


I'm feeling like a bit of an API veteran now, in that I haven't broken the database yet after a couple of projects :)


I've got several import profiles set up to feed bulk information into RE - mostly actions, such as recording changes of subscription that add solicit codes and populate with an action to back it up. All pretty straightforward.


One of the most common imports I use is to populate with records of email sends - I've got a fairly standard import that takes the file that was uploaded to the email send client, and populates each of the constituents with an action saying the email was attempted to be sent on a certain date, with the notepad recording the subject line and the body of the email. That way it builds up a library of emails that were sent to the person. I've recently been adding in subsequent uploads a few weeks later that upload analytics from the email sent client, which are recorded as attributes. So for example, I might upload details of a fundraising appeal against the constituents who were sent it, then against the same action the attributes are populated with the date it was opened, whether links were clicked and whether the email bounced or was unsubscribed to.


Using the IOM settings of matching Actions by date, type and category, it's been working pretty well - the problems I'm getting are when there's multiple emails sent to the same recipient in the same day, so the date of the two actions are the same; being the same type and category, it can't tell which one is the action you want, so it throws an exception.


So the plan is to use the notepad subject line in the API code to find the right action, but the actual outcome is something I'm unsure about. This is what I have set up to find the right action, with the additional code in yellow:


Imports Microsoft.VisualBasic

Imports System

Imports System.Linq

Imports Blackbaud.PIA.RE7.BBREAPI

 

'This code is specific to your current profile

 

Public Class Profile

    Inherits ImportOM.API.ProfileBase

  Private EmailSub As String = String.Empty

 

    Public Overrides Sub BeforeImport(ByVal Cancel As ImportOM.API.iCancel)

  'Import has not been started yet

 EmailSub = InputBox("Paste in Email Title")

 End Sub


...   


    Public Overrides Sub BeforeConstituentSave(ByVal oRec As Blackbaud.PIA.RE7.BBREAPI.CRecord, _

                                        Cancel as ImportOM.API.iCancel)

        'The main constituent record is about to be saved

    Dim oAction As Blackbaud.PIA.RE7.BBREAPI.CAction

 

For Each oAction In oRec.Actions 

If oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_NOTEPAD_DESCRIPTION)= Emailsub And oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE) = import.Fields.GetByExcelName("H") Then 


Else


End If

Next oAction

 

    End Sub


...


Column H is the date that the outcome was recorded, and matches with the Action date already there. I have virtual fields set up to populate the attributes off the back of one spreadsheet field (like using one date multiple times) but other than that everything is in the upload.


My question would be how to best execute the attribute population:


  • Should I set all of the upload fields to Ignore, and have it cycle through all actions before triggering a series of field updates in the API, so the import doesn't actually import anything, just carries the information?
  • Should I set it to check if it's the right action, and blank out the import information if it's wrong? I have a feeling this would essentially null value the entire import for that line if it doesn't succeed first time, so is there a way to just make it not import if it's the wrong action, do a Next oAction and try again?
  • Something else I've not thought of?

I'm leaning towards the first one, but was wondering if there's a better and more elegant solution.


I'd say option number 1.  


A couple of other suggestions.  With vb.net you an assign the variable value at the same time you declare it so you could get rid of Dim oAction As Blackbaud.PIA.RE7.BBREAPI.CAction and instead change your for each statement to "For Each oAction as CAction In oRec.Actions".  Nothing wrong with the way you have it now, but this streamlines it a bit.  Also make sure when you are looping through objects you are closing them when you're done with them:


For Each oAction as CAction In oRec.Actions

 

If oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_NOTEPAD_DESCRIPTION)= Emailsub And oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE) = import.Fields.GetByExcelName("H") Then

Else

End If


oAction.closedown()

oAction = Nothing

 

Next oAction


Thanks,


John

Thanks John - I'll tidy up the code a little before deploying it in earnest.


I wasn't sure if there was an easy way to be able to say essentially:


For each input row...

Check each Action on the record

Is this the Action that matches the Type, Date, Category and the InputBox string?

No? That's a shame, don't do anything just yet, just keep looking

Yes? Awesome, action that import line as normal.

Next row.


I'm happy to have it all updated via the API, so not actually use IOM to import at all, but just to check the records and update the fields directly in RE - wanted to check if I was missing something that would allow me to say to only use the import profile once the right Action had been found.

Hi Adam,

We are using the Luminate Connector and would like to start pulling in email activity by setting up one of the import profiles.  I was wondering if you would be willing to share how you set up your action attributes in RE?  Are you finding them useful so far?  Do you have any tips?  Are you on NXT?


Thanks!

Tiffany

Login to post a comment