cancel
Showing results for 
Search instead for 
Did you mean: 

How to add Valid values in user field?

Former Member
0 Kudos

Hi,

I'm trying to add a user field (valid values) in my user table, but i don't know what's wrong with my code.

It creates the field, but not the field that i want.

 oUserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)

            oUserFieldsMD.TableName = sTableName
            oUserFieldsMD.Name = sFieldName
            oUserFieldsMD.Description = sDescription
            oUserFieldsMD.Type = FieldType
            oUserFieldsMD.Size = iSize

            'Valid Values 1

            oUserFieldsMD.ValidValues.Value = "D"
            oUserFieldsMD.ValidValues.Description = "Disable"
            oUserFieldsMD.ValidValues.Add()
            oUserFieldsMD.DefaultValue = "D"
            'Valid Values 2

            oUserFieldsMD.ValidValues.Value = "A"
            oUserFieldsMD.ValidValues.Description = "Active"
            oUserFieldsMD.ValidValues.Add()
           
            Dim i As Integer
            Dim err As String

            i = oUserFieldsMD.Add()
            If i <> 0 Then
                oCompany.GetLastError(i, err)
                SBO_Application.MessageBox(i & "; " & err)
            End If

Bruce

Accepted Solutions (1)

Accepted Solutions (1)

former_member184566
Active Contributor
0 Kudos

Hi Bruce

It looks good, just take out the second one "UserFieldsMD.ValidValues.Add()". Leave the first one. Just take out the second one after oUserFieldsMD.ValidValues.Description = "Active"

Hope this helps

Answers (0)