on 2009 Oct 27 7:57 PM
Hello all,
im wondering if is possible to delete a user field by code, i already add user field using this code:
Private Sub CrearCampoUsuarioTemporal()
Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD
Try
oUserFieldsMD = Conexion.ObtenerObjetoSBO(SAPbobsCOM.BoObjectTypes.oUserFields) 'obtenemos un objeto de tipo campo de usuario proveniente de SBO.
oUserFieldsMD.TableName = Format("OINV") 'Seleccionamos la tabla a la que deseamos agregarle el nuevo campo de usuario.
oUserFieldsMD.Name = Format("TEMP_BPV_NCON") 'Asignamos el nombre del campo de usuario que vamos a crear.
oUserFieldsMD.Description = Format("Número de Control Temporal") 'Asignamos la descripcion del nuevo campo de usuario.
oUserFieldsMD.Type = SAPbobsCOM.BoFieldTypes.db_Alpha 'Asignamos el tipo de data que va a contener el campo de usuario.
oUserFieldsMD.EditSize = 10 'Asignamos el tamaño de caracteres que va a soportar el nuevo campo.
oUserFieldsMD.SubType = SAPbobsCOM.BoFldSubTypes.st_None 'Asignamos el subtipo del campo
m_iErrCode = oUserFieldsMD.Add 'Agregamos el nuevo campo a SBO
If Not m_iErrCode = 0 And m_iErrCode <> -2035 Then 'Verificamos que la creacion se haya realizado con exito
Conexion.ObtenerErroresSBO(m_iErrCode, m_sErrMsg) 'Obtenemos el mensaje de creacion del campo
MsgBox(m_sErrMsg) 'Enviamos mensaje de error
Me.Close()
Start.Close()
End If
If oUserFieldsMD IsNot Nothing Then System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFieldsMD) 'Verificamos que el objeto con el que creamos el campo no se encuentre vacio y lo desacoplamos de la memoria
oUserFieldsMD = Nothing 'igualamos el objeto a Nothing
GC.Collect() 'Invocamos al Garbage Colector (Colector de Basura) para liberar el objeto de memoria.
pb_Progreso.Increment(5) 'Incremetamos la barra de progreso
chk_CamposUsuarioAux.Checked = True 'Marcamos la tarea como realizada
Catch ex As Exception
MsgBox(ex.Message) 'Mesaje de error ocurrido en la rutina .Net
Me.Close()
End Try
End Sub
Now im trying to delete it by code if any1 can help me plz
thx alot...
Request clarification before answering.
Hello Oscar,
you can use the Remove function of the UserFieldsMD object. Before you call it , you should use GetByKey(tablename,fieldname) function to receive the object.
Private Function RemoveUDF(ByVal TableName As String, ByVal FieldName As String) As Boolean
Dim oUserFieldsMD As SAPbobsCOM.UserFieldsMD = oCompany.GetBusinessObject(BoObjectTypes.oUserFields)
Try
If oUserFieldsMD.GetByKey(TableName, FieldName) = False Then
Return True ' Field does not exists
End If
If oUserFieldsMD.Remove = 0 Then
Return True
Else
MsgBox(String.Format("{0}-{1}", oCompany.GetLastErrorCode, oCompany.GetLastErrorDescription))
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
Regards,
J.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
15 | |
10 | |
8 | |
5 | |
3 | |
3 | |
3 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.