on 05-16-2019 3:24 PM
The below code is working fine for me. You can give it a try and let me know:
SAPbobsCOM.UserObjectsMD oUserObjectMD = null;
SAPbobsCOM.UserObjectMD_FindColumns oUDOFind = null;
SAPbobsCOM.UserObjectMD_FormColumns oUDOForm = null;
SAPbobsCOM.UserObjectMD_EnhancedFormColumns oUDOEnhancedForm = null;
GC.Collect();
oUserObjectMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserObjectsMD) as SAPbobsCOM.UserObjectsMD;
oUDOFind = oUserObjectMD.FindColumns;
oUDOForm = oUserObjectMD.FormColumns;
oUDOEnhancedForm = oUserObjectMD.EnhancedFormColumns;
var retval = oUserObjectMD.GetByKey("UDOCODE");
if (!retval)
{
oUserObjectMD.Code = "UDOCODE";
oUserObjectMD.Name = "NAME";
oUserObjectMD.TableName = "UDOTABLE";
oUserObjectMD.ObjectType = SAPbobsCOM.BoUDOObjType.boud_MasterData;
oUserObjectMD.CanFind = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.CanDelete = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.CanCancel = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.CanClose = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.CanYearTransfer = SAPbobsCOM.BoYesNoEnum.tNO;
oUserObjectMD.CanLog = SAPbobsCOM.BoYesNoEnum.tNO;
oUserObjectMD.ManageSeries = SAPbobsCOM.BoYesNoEnum.tNO;
oUserObjectMD.CanCreateDefaultForm = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.MenuItem = SAPbobsCOM.BoYesNoEnum.tYES;
oUserObjectMD.EnableEnhancedForm = SAPbobsCOM.BoYesNoEnum.tNO;
oUserObjectMD.MenuCaption = "Menu Caption";
oUserObjectMD.FatherMenuID = 48896;
oUserObjectMD.MenuUID = "UDOMenuUID";
oUserObjectMD.Position = 5;
// ==================================
oUDOFind.ColumnAlias = "Code";
oUDOFind.ColumnDescription = "Code";
oUDOFind.Add();
oUDOFind.ColumnAlias = "Name";
oUDOFind.ColumnDescription = "Name";
oUDOFind.Add();
//========================================
//=========================================
oUDOForm.FormColumnAlias = "Code";
oUDOForm.FormColumnDescription = "Code";
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
oUDOForm.Add();
oUDOForm.FormColumnAlias = "U_FirstName";
oUDOForm.FormColumnDescription = "U_First Name";
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
oUDOForm.Add();
oUDOForm.FormColumnAlias = "U_Email";
oUDOForm.FormColumnDescription = "Email";
oUDOForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
oUDOForm.Add();
//=========================================
oUDOEnhancedForm.ColumnAlias = "Code";
oUDOEnhancedForm.ColumnDescription = "Code";
oUDOEnhancedForm.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES;
oUDOEnhancedForm.ColumnNumber = 1;
oUDOEnhancedForm.ChildNumber = 1;
oUDOEnhancedForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
oUDOEnhancedForm.Add();
oUDOEnhancedForm.ColumnAlias = "U_FirstName";
oUDOEnhancedForm.ColumnDescription = "First Name";
oUDOEnhancedForm.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES;
oUDOEnhancedForm.ColumnNumber = 2;
oUDOEnhancedForm.ChildNumber = 1;
oUDOEnhancedForm.Add();
oUDOEnhancedForm.ColumnAlias = "U_Email";
oUDOEnhancedForm.ColumnDescription = "Email";
oUDOEnhancedForm.ColumnIsUsed = SAPbobsCOM.BoYesNoEnum.tYES;
oUDOEnhancedForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
oUDOEnhancedForm.ColumnNumber = 3;
oUDOEnhancedForm.ChildNumber = 1;
oUDOEnhancedForm.Editable = SAPbobsCOM.BoYesNoEnum.tYES;
oUDOEnhancedForm.Add();
if (!retval)
{
if ((oUserObjectMD.Add() != 0))
{
MessageBox.Show(oCompany.GetLastErrorDescription());
}
else
{
}
}
}
Kind regards,
ANKIT CHAUHAN
SAP Business One Support
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
9 | |
6 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.