Start a new topic

Virtual Field name not being picked up by function

Hi Forum,

I have

    Incoming Column C

    Virtual Field BS


I have a function in the Virtual Field BS that replaces the incoming non-blank value with text stored in the field name of BS.

At least that is what I intended, but the oField.Name is only returning the value of field name in Column C, not BS, even though the function is in BS.

How do I get the Virtual field name instead?

 Public Function ComputedColumn_635743005844624803( _
    ByVal oField as ImportOM.API.iField, _
    ByVal Cancel As ImportOM.API.iCancel) As String

  'This function must return a text value
  'this replaces data in a non-empty field with the feld name instead
  'Like a custom static field.

  Dim sReturn As String = ""

  If cstr(oField.Value)"" Then
  End If

  Return sReturn
 End Function


Kind regards


In a custom function oField can represent two different fields depending on the settings.

If there is a SEED field set then oField represents that field (usually the case for Virtual Fields)

If there is not a SEED field set then oField represents the field that is assigned the function.

Either way, the value returned will always go to the field that is assigned to the function.

So in this case I am assuming that you have the function assigned to field BS and the seed assigned to C which means that oField is actually C and not BS.
Hi Wayne,

Yes, if C is populated I want to return the value of the BS name - like using a static field.

I wanted a generic code way to do it, as we will need it in many imports.

Is there a way to get the BS field name?
I have an idea.

If remove the seed and use ":" character as a separator, I can change the Field name of BS to
and parse it in code, C being the original column to look up and the rest of the value being the BS field name.

I'll see if it works.
Since you are working with two different fields one of them will need to be hard coded in the function.

You could either not include a seed and specifically look up the "C" column in the function and use oField to look up the name of BS (as you have done) or you could have this function assigned to the C column and specifically look up the BS column in the function (although that would probably be equivalent to just hard coding the name of the BS column).

Otherwise you might be able to achieve the same outcome using a dictionary or RE default set depending on what this data is being used for.
That sounds like a clever solution Hope!
Login or Signup to post a comment