Skip to Content
avatar image
Former Member

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

Hi.

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Apr 11, 2017 at 10:30 PM

    Hi Saad,

    I believe there is no way to set a default value for a date with function like GETDATE(), you can just set a fixed date. :(

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded