Start a new topic

Letter code based on gift amount

Does anyone know of a way to set a virtual field or dictionary for Letter Code based on Gift Amount? Gifts of $1000 or more have one letter code, gifts under $1000 have another code.

Hi Marie,

This sounds like a good candidate for a simple custom function.  Below I have given you a sample.  You would set this custom function as the "Function" of the virtual column and set the "Seed" to be the column with the gift amount.

If oField.Value  
For more information on how to create a custom function see
Thank you, Wayne. I have not created a function before, but I will give it a try!
May I call upon your help one more time?
I have been asked to do the following. If the gift is under $1000, then copy the gift date and populate the Acknowledge Date. If the gift is over $1000, then leave the Acknowledge Date blank.
Thank you!

Hi Marie,

You can use the "seed" functionality to do this pretty easily.  When you set a field as the "seed" for a function then that field becomes the oField in your custom function.  If you do not set a seed field then it is assumed that you want the current field to be the oField value.

So you would need to create a function similar to the last one here and assume that oField is your amount field (because you will set that field as the seed column).  Then the logic is pretty straight-forward, just replace = "" with >= 1000 and you should be most of the way there!


I'm having some trouble with this. When the value is less than $1000, it is giving me a dollar value in the acknowledgement date. I will always have a gift value. What I want to do is copy the gift date from another column if the gift amount is less tahn $1000. I'm not sure how to do this.
since oField is the amounts field and sReturn is what the Acknowledge Date field will be set to you need to separate the two.

The way the original function was written you set sReturn (value of the Ack Date field) = oField.Value (value of the amount field) at the beginning. Then you only change sReturn if the amount is > $1,000 so it stays set to the amount if it is
Either you can use an Else clause in your If statement (i.e. If sReturn > 1000 Then sReturn = Ack Date ELSE sReturn = "" End If) or you can start by setting sReturn = "" and use oField.Value in your If statement so that if the amount is
I have this working now. Thanks again for your help, Wayne.
Try this:

If oField.Value "Canada" Then

Or even better, this:

If oField.Value.ToUpper "CANADA" Then

Didn't actually try this, so I'm assuming Value is a string that will have the ToUpper function. But this will make sure it works even if the source data is "Canada", "CANADA", or "cAnAdA".
To add on to Jeff's response, to have access to another "seed" or field you would need to specifically call it like this:


So something like:

If oField.Value.ToUpper "CANADA" Or Import.Fields.GetByName("GiftAmount").Value sReturn = "Do Not Receipt"
sReturn = "Not Receipted"
End if
Wayne, where does the cursor go when I click on Add Virtual Column? I can't see most of the screen prints.
Thank you.
Imports Microsoft.VisualBasic
Imports System
Imports System.Linq

'This code is specific to your current profile

Public Class Profile

    Inherits ImportOM.API.ProfileBase

--> Cursor Here

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

'Import has not been started yet

End Sub

Thanks for your help Wayne. I can't get this to work though. I added the code, I see it as a Function, and picked the seed column. I don't
get any errors when I test the code, but the letter code does not populate. I''m not sure what I am missing.
Marie, can you post all your relevant code?
Make sure that you selected the function as well as the seed.

If the letter is ending up blank then the function is not running because the function would set one of those values.
This is my code
Public Function ComputedColumn_635405005490884063( _
ByVal oField as ImportOM.API.iField, _
ByVal Cancel As ImportOM.API.iCancel) As String
'This function must return a text value
Dim sReturn As String = ""
Return sReturn

If oField.Value sReturn = "OR-Online Receipt"
sReturn = "MCHF-Receipt"
End If
End Function

In my virtual field, I have the function Test Letter Code, and the Seed is N, which is the column for Gift Amount.
Login or Signup to post a comment