Skip to Content
Former Member
Apr 11, 2017 at 04:00 PM

Set Default value in user defined field while adding used defined in Table



I want to add user defined field with default value in database. User field is added successfully and it returns zero on adding field. But when i check in database, there is no default value set there. I'm setting default value as "GETDATE()" for date field. Default value remains empty in database.

Here is my code:
Dim v_UserField As SAPbobsCOM.UserFieldsMD 'v_UserField = goParent.goDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields) 'v_UserField.TableName = "@IDH_ACTLOG" 'v_UserField.Name = "test1" 'v_UserField.Description = "test1" 'v_UserField.Type = SAPbobsCOM.BoFieldTypes.db_Date 'v_UserField.SubType = SAPbobsCOM.BoFldSubTypes.st_None 'v_UserField.Size = 10 'v_UserField.DefaultValue = "getdate()" 'Dim v_RetVal As Integer = v_UserField.Add() 'If v_RetVal = 0 Then ' com.idh.bridge.DataHandler.INSTANCE.doError("default value added successfully") 'Else ' com.idh.bridge.DataHandler.INSTANCE.doError("Failed to add default value") 'End If


fwerfw.png (191.4 kB)