Hi
I have beloe code for creating connection in Sap b1. I want to add button in Sales Order form.
int res = 0;
string strret = "";
SAPbobsCOM.Company oCompany = new SAPbobsCOM.Company();
oCompany.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2008;
oCompany.Server = "127.0.0.1";
oCompany.UseTrusted = false;
oCompany.CompanyDB = "db_name";
oCompany.UserName = "SomeUser";
oCompany.Password = "******";
oCompany.Connect();
oCompany.GetLastError(out res, out strret);
strret = oCompany.GetLastErrorDescription();
MessageBox.Show(strret);
Can anyone help
Thanks
Tuhin PaulPosted Feb 6, 2025, 7:50 PM
To add a button to the Sales Order form in SAP Business One (SAP B1) using C#, you need to use the SAP Business One SDK . Specifically, you will work with the User Interface API to customize forms and add buttons.
Below is an explanation of how to modify your existing code to add a button to the Sales Order form. See how you can modify your code to add a button to the Sales Order form:
Connecting to SAP Business One:
oCompany.Connect()method establishes a connection to the SAP Business One database.Accessing the SAP Business One Application Object:
System.Runtime.InteropServices.Marshal.GetActiveObjectmethod retrieves the active instance of the SAP Business One application.Accessing the Sales Order Form:
oApplication.Forms.Item("139")method accesses the Sales Order form. The"139"is the unique identifier for the Sales Order form.Adding a Button:
Items.Addmethod.ItemandButtonobjects.Handling Button Click Events:
Application_ItemEventmethod handles events on the form.MyCustomButton) is clicked, a message box is displayed.Muhammad Imran AnsariPosted Feb 6, 2025, 5:18 PM
Hello Ramco,
To add a button to the Sales Order form in SAP Business One (SAP B1), you need to use the SAP B1 SDK (Software Development Kit) to create an add-on or extension. The code you provided is for connecting to the SAP B1 company database, but you need to extend it to include the logic for adding a button to the Sales Order form.
Set Up Your Development Environment
Ensure you have the SAP B1 SDK installed.
Use Visual Studio to create a new C# project (e.g., a Class Library or Windows Forms project).
Add references to the SAP B1 SDK libraries (e.g.,
SAPbobsCOM.dllandSAPbouiCOM.dll).Create the Button on the Sales Order Form
Use the
SAPbouiCOMnamespace to interact with the SAP B1 user interface.Add a button to the Sales Order form (
139is the form type for Sales Orders).Here’s an example of how to add a button:
Key Notes:
Ensure you have the necessary permissions to modify forms in SAP B1.
The button position (
Left,Top,Width,Height) can be adjusted as needed.You can extend the
Button_Clickmethod to perform any custom logic you needSarthak VarshneyPosted Feb 6, 2025, 4:08 PM
You can add a button to the Sales Order form in SAP Business One using the SAP Business One UI API. Below is an example of how you can achieve this:
Steps to Add a Button in the Sales Order Form
ORDR- Form Type 139).Updated Code to Add a Button
Explanation of Code
Connecting to SAP Business One
SboGuiApito connect to the UI API.Adding a Button to the Sales Order Form
btnCustom).Handling the Button Click Event
ItemEvent.btnCustom).