UDF as Checkbox on a loaded Matrix
Sebastian Schweer
Hi Everybody,i try to do the following:
I want to add a column to the Country Table in B1 as UDF and as a checkbox.
Country Table under Administration -> Setup -> Business Partners -> Countries.
So add a UDF via the following customize code as Alphanumeric 1:
[CODE] SAPbobsCOM.UserFieldsMD userFieldsCF = (SAPbobsCOM.UserFieldsMD) SwissAddonFramework.B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);
userFieldsCF.Name = "BEU_ISASEAN";
userFieldsCF.Description = "Is Asean";
userFieldsCF.Type = SAPbobsCOM.BoFieldTypes.db_Alpha ;
userFieldsCF.SubType = SAPbobsCOM.BoFldSubTypes.st_None;
userFieldsCF.EditSize = 1;
int errCodeCF = userFieldsCF.Add();
if (errCodeCF != 0)
{
string errMsg;
SwissAddonFramework.B1Connector.GetB1Connector().Company.GetLastError(out errCodeCF, out errMsg);
StatusBar.WriteError(errCodeCF + " - " + errMsg);
}
[/CODE]
Until there, there is no problem. The field is created on the Matrix with no problems.
But how can i change this field to a checkbox column ?
Is it possible to create a UDF as checkbox Field from the beginning?
Also I tried it with the following code to change the column to a checkbox but it dosen't work:
[CODE]Matrix mx = Matrix.GetFromUID(pVal.Form, "3");
mx.Columns["U_BEU_ISASEAN"].Type = SwissAddonFramework.UI.Components.MatrixColumn.MatrixItemType.CheckBox;[/CODE]
But it dosen't work.Every time he tolds me the following:
"Error occur: Type is not allowed on an loaded matrix column."
Have anyone an idea?
I use Form Load and Before Event already.
Best Regards and thanks for your help,
Sebastian
Paolo Manfrin
Hi Sebastian,as far as I remember to have a checkbox column you need Alphanumeric1 with 2 valid values Y, Yes and N,No mandatory
Even when you create this column via the SAP Menu you should be able to get a checkbox.
Try out and let me know.
cheers,
paolo
Sebastian Schweer
Hi Paolo,thanks for your help.
For everyone who wants to know, here is the code:
[CODE]
// Define an new User Defiened Field Object
SAPbobsCOM.UserFieldsMD userFieldsCF = (SAPbobsCOM.UserFieldsMD) SwissAddonFramework.B1Connector.GetB1Connector().Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields);
// Filling the new UDF with Data
userFieldsCF.TableName = "OCRY";
userFieldsCF.Name = "BEU_ISASEAN";
userFieldsCF.Description = "ASEAN";
userFieldsCF.Type = SAPbobsCOM.BoFieldTypes.db_Alpha ;
userFieldsCF.SubType = SAPbobsCOM.BoFldSubTypes.st_None;
userFieldsCF.EditSize = 1;
// add Valid Values
userFieldsCF.ValidValues.Value = "Y";
userFieldsCF.ValidValues.Add();
userFieldsCF.ValidValues.Value = "N";
userFieldsCF.ValidValues.Add();
int errCodeCF = userFieldsCF.Add();
if (errCodeCF != 0)
{
string errMsg;
SwissAddonFramework.B1Connector.GetB1Connector().Company.GetLastError(out errCodeCF, out errMsg);
StatusBar.WriteError(errCodeCF + " - " + errMsg);
}
else
{
StatusBar.WriteSucess("UDF created successfully");
} [/CODE]
Best Regards,
Sebastian
0
Please sign in to leave a comment.
Comments
0 comments