Hi John
I work at the same place as Helen, and she has asked me to follow up on this one, as I have now hit the same problem. I am trying to use the static field name to only populate if a seed field is populated.
We have to add an action to those people in a file who have a certain field in the file populated. The action is not in the file. It would be easiest for our data execs to have this built into the import, rather than having to run a second import, or run a global add after the import has taken place.
So I need something that says along the lines of :
If oField IsNot Nothing
If oField.Value.Trim "" Then
sReturn = Static field (field name)
Except I know it isn't going to be as simple as that!!
I'd rather not use dictionaries as there are several fields I will need to standard populate on this action, and that would mean a fair few dictionaries for one import.
Many thanks
Gemma
Helen and Gemma-
Did you ever get this working? I did something that I think is close to what you are trying to do. You can create a virtual field (mapped, but without a function) and use VB to fill-in what you want in that field, or in multiple fields.
This code below is adjusting the Letter Type (virtual field BK, which is mapped to the letter type, but no function applied) based on a couple things:
I didn't copy the rest of the code, but it also does stuff like referencing the donor's Prospect Classification to assign our general ledger codes (Leadership donors go to a different fund at our organization).
I inserted this after Public Class Profile Inherits ImportOM.API.ProfileBase:
Public function GetColumn(ColumnName As String) As String
GetColumn = Import.Fields.GetByExcelName(ColumnName).Value
End function
Public sub SetColumn(ColumnName As String, StrValue as string)
Import.Fields.GetByExcelName(ColumnName).Value = StrValue
End sub
And this in the AfterConstituentOpen section:
'define source column names
Dim sSource = "G"
Dim sDonation = "Y"
Dim sAddress = "AC"
'define virtual column names
Dim vLetterCode = "BK"
'By default the lettercode will be General
SetColumn(vLetterCode, "General")
'Change the letter code if memory or honor is found
If GetColumn(sDonation).Contains("Memorial") Then
SetColumn(vLetterCode, "Memorial")
'if the record contains an address, add the card designation to the letter code
If GetColumn(sAddress).Length > 0 Then
SetColumn(vLetterCode, "Memorial - Card")
End if
End if
If GetColumn(sDonation).Contains("Tribute") then
SetColumn(vLetterCode, "Tribute")
'if the record contains an address, add the card designation to the letter code
If GetColumn(sAddress).Length > 0 Then
SetColumn(vLetterCode, "Tribute- Card")
End if
'Change the letter code if Telemarketing gift
If GetColumn(sSource).Contains("17TM") Then
SetColumn(vLetterCode, "Telemarketing")
End if
End If
I'm still learning this stuff, but it's amazing what can be done. I'm sure there are other ways to do the VB, but this has worked well for us. (you can use the column letters instead of defining them by a name, but I do the DIM statements so that it's easier to update if the incoming field order or number changes)
Hi Barbara
This is definitely going to be helpful! Thank you so much!
Kind regards
Gemma
Helen Chambers
IOM has a built in function called Static field (field name) and I essentially want to use it but only in particular scenarios.
Without writing the code I am trying to do the following
If seed field = 'Y' then import field value = virtual field name
I have all the code figured out apart from how to reference the virtual field name.
Can anyone point be in the right direction?
Thanks!
Helen