Posted By Wayne Pozzar on 27 Oct 2014 11:57 AM
What does your import profile look like? Do you have a column for each new action? One action per row?
I've got one action per Column.
ex.
AS-Attended 2006 Gala 05.27.2006-Action-Type-1- no dictionary
AS | Attended 2006 Gala 05.27.2006 | Action | Type | 1 |
AT | Attended Animalerie 10.22.04 | Action | Type | 1 |
AU | Attended Big Bend 3.31.2011 | Action | Type | 1 |
AV | Attended Bittersweet Harvest 2.25.2011 | Action | Type | 1 |
AW | Attended Buck Winn 12.7.2010 | Action | Type | 1 |
This is what part of the profile looks like. I have almost 30 actions total, each action is listed in a single column as a action type.
Let me know if that helps at all.
Original
ID | Action 1 | Action 2 |
1 | Yes | Yes |
2 | No | Yes |
ID | Action |
1 | Action 1 |
1 | Action 2 |
2 | Action 2 |
That way you can key off of the action name and get the appropriate dates & values
Then I would make dictionaries for each of the values that you need to add (just need Date and Category I think since the dates are the same)
A date dictionary would be something like
Value | Match |
7/1/2013 | Action 1 |
8/1/2013 | Action 2 |
And category dictionary
Value | Match |
Task/Other | Action 1 |
Meeting | Action 2 |
You can make these in excel first and then copy them into dictionaries with a right click.
Then you could make a profile like this
Column | Field Name | Record Type | Value Type | # | Function | SEED | Dictionary |
A | ID | Constituent | ID | ||||
B | Action | Action | Type | 1 | |||
Virtual | Date | Action | Date | 1 | Copy Field | B | DateDictionary |
Virtual | Completed Date | Action | Completed Date | 1 | Copy Field | B | DateDictionary |
Virtual | Date Added | Action | Date Added | 1 | Copy Field | B | DateDictionary |
Virtual | Category | Action | Category | 1 | Copy Field | B | CategoryDictionary |
Then, when you run the import, it will look up the date & category based on the action name and create the action!
Posted By Wayne Pozzar on 27 Oct 2014 03:29 PM
Wow!
This is not an easy import.
No kidding,
The dataset is currently almost 6000 records strong. I was hoping to avoid having to rewrite the entire file. If I can't code it though, I've been discussing whether or not it may be easier to just do a glogal change (to add all the actions) once all the records are imported. Thanks for the help Wayne, If you are able to figure out any other way to get this done or have any other suggestions I'm open to options; I'm not throwing out the idea of modifying the import file either.
Thanks again for the help,
Matt
Posted By Wayne Pozzar on 28 Oct 2014 09:17 AM
It wouldn't be hard to change the file from the current format to the one I suggested.
If you want to email it to me I can do it quickly.
Two other suggestions would be to create a custom function for each action/column that sets the relevant data or use excel to add the relevant data columns to the import file using index/match.
I haven't tried either of those yet, I was messing with it earlier (before I saw your comments) and I can get the script to actually run if I run it as a second pass. So I import the files and then run a second pass to modify the actions that are imported through the profile. I also added some msgbox(es) to work as breaks to help me determine how far I'm getting.
From what I've figured out is its getting past the
"For Each oAction In oRec.Actions"
and then it's erroring telling me that
"Error in custom code BeforeConstituentSave: Public member 'Value' on type 'String' not found. Line:0 -->ImportOM.CImport.Process()"
Any ideas what might be causing this error?
Here's the modified code:
For Each oAction In oRec.Actions
msgbox("Action started")
If (
oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EActionFields.Action_fld_type).Value.Contains("Attended 2006 Gala 5-27-2006"))Then
msgbox("found attended event")
oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_COMPLETED_DATE).Value="05/27/2006"
msgbox("date completed modified")
oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE).Value="05/27/2006"
msgbox("date field modified")
oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_DATE_ADDED).Value="05/27/2006"
msgbox("date added modified")
oAction.Fields(Blackbaud.PIA.RE7.BBREAPI.EACTIONFields.ACTION_fld_CATEGORY).Value="Task/Other"
msgbox("action category modified")
If all else fails Wayne, I might see about sending you the action section of the excel doc.
@Geraldo I tried adding the oAction.Save earlier and it seems it's not even getting that far to have any information to save, but if I get that far and it's still giving me an error I'll keep that in mind too.
Posted By Wayne Pozzar on 28 Oct 2014 04:09 PM
Ah, when dealing with RE API fields you don't need .Value
You can just remove them!
I'll give that a try and let you know if that fixes the issue.
Thanks!
Matthew Dwight
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