Working With SAP Business One Script: All Countries
Working With SAP Business One Script: All Countries
Example Words or characters quoted from the screen. These include field names, screen titles,
pushbuttons labels, menu names, menu paths, and menu options.
Textual cross-references to other documents.
EXAMPLE Technical names of system objects. These include report names, program names,
transaction codes, table names, and key concepts of a programming language when they
are surrounded by body text, for example, SELECT and INCLUDE.
Example Output on the screen. This includes file and directory names and their paths, messages,
names of variables and parameters, source text, and names of installation, upgrade and
database tools.
Example Exact user entry. These are words or characters that you enter in the system exactly as they
appear in the documentation.
<Example> Variable user entry. Angle brackets indicate that you replace these words and characters
with appropriate entries to make entries in the system.
1 Introduction .................................................................................................................................................... 5
1.1 Prerequisites ............................................................................................................................................................ 5
1.2 Glossary .................................................................................................................................................................... 5
SAP Business One Script is a lightweight, JavaScript-based extension system that you can use to quickly adapt
SAP Business One to business-specific processes in cloud environments.
Unlike traditional SAP Business One add-ons, these extensions are "sandboxed", with managed access to system
functionality. SAP Business One Script enables you to quickly and cheaply develop solutions that address last-
mile extensibility, without the need for certification.
1.1 Prerequisites
1.2 Glossary
Field Description
SAP Business One Cloud SAP Business One Cloud is the SAP cloud solution for small businesses
and subsidiaries of large enterprises. SAP Business One is centrally
hosted by partners in data centers. Providers license the application to
customers for use as a service when they need it, that is, “on demand.”
It eliminates the need for on-site IT resources to manage infrastructure
and thereby reduces operational expenses.
Script A small program that automates the execution of simple tasks in SAP
Business One. The application executes scripts on-the-fly.
JavaScript The scripting language you use to create SAP Business One scripts.
Debugger An application that enables you to test and debug scripts. Debuggers
typically allow you to run a script step-by-step, and stop a script at a
specific point or when certain defined conditions are satisfied.
Form (Window) Displays the details of a record or page and provides a means of data
entry for users. In SAP Business One, each form has a unique
identification number, which you can use to bind scripts to specific
forms.
Debug Port Facilitates communication between the SAP Business One Script
debugging service and the debugger, which is typically a Web browser.
To debug scripts, you must first start the debug port in SAP Business
One.
Add-On Program that offers additional functionality for SAP Business One. All
add-ons are technically dependent on and can be installed on top of
SAP Business One.
System Landscape Directory (SLD) A central directory of all SAP Business One components in a cloud
Database landscape.
Service Unit A collection of the software components, servers, and storage required
to provide access to a full SAP Business One installation. All SAP
Business One components in a single service unit have the same
version. A single service unit can contain multiple tenants with similar
requirements.
Procedure
Caution
To enable SAP Business One Script, you must have superuser permissions in SAP Business One.
1. From the SAP Business One Main Menu, choose Administration → Add-Ons → Add-On Manager.
The Add-On Manager window appears.
2. On the Installed Add-Ons tab, select SBOScript, and then choose the Start button.
3. To save your changes, choose the OK button.
Result
The following windows are available from the SAP Business One Main Menu:
• Administration → Extension Management → Script Settings
Prerequisite
You have enables SAP Business One Script. For more information, see Enabling SAP Business One Script.
Procedure
To configure the required settings for SAP Business One script, do the following:
1. From the SAP Business One Main Menu, choose Administration → Extension Management → Script Settings.
The Script Settings window appears.
Note
Notepad is installed by default with Microsoft Windows; however, to use Eclipse, you must manually
install the application.
o To edit scripts using another editor, select the Other Editor checkbox, and then enter the path to the
application executable on your computer.
3. On the Debugger tab, do either of the following:
o To debug scripts using the built-in debugger of Google Chrome or Mozilla Firefox, select the
corresponding checkbox.
Note
To debug scripts using Google Chrome or Mozilla Firefox, you must manually install either application.
Procedure
2. Right-click anywhere in the header row, and then from the context menu, choose Import Script.
The Select Scripts window appears.
3. Select a valid JavaScript file, and then choose the Open button.
4. In the Script Manager window, enter the following information:
o Partner Name – The author of the script.
o Script Name – The name of the script.
o Binding Form – The SAP Business One form on which the script acts.
Result
The application copies the JavaScript code to the SLD database and displays the selected script in the Script
Manager window. For more information, see Running Scripts.
Procedure
Prerequisite
You have imported an SAP Business One script, or created a new script, and the script is bound to an SAP
Business One form.
Procedure
Result
After opening the window, the application automatically runs the script.
You can edit scripts using the built-in editor of SAP Business One or an external editor.
Prerequisite
To edit scripts in an external editor, you have installed the application on your computer and entered the file path
in the Script Settings window. For more information, see Configuring SAP Business One Script.
Procedure
Result
The application updates the JavaScript code belonging to the script in the SLD database and removes any
temporary files created in external editing processes.
Prerequisites
Procedure
Procedure
The following example script is bound to form 134, which corresponds to the Business Partner Master Data
window in SAP Business One. After opening the Business Partner Master Data window, the script performs a
check on the E-Mail field for the presence of the "@" symbol. If the symbol is present, the script sets the
background color of the field to green; otherwise, the script sets the background color to red.
Example
var LostFocusCallBack = function(itemEvent)
{
var oEditText = this.Specific;
var text = oEditText.String;
if(text.indexOf("@") == -1)
{
this.BackColor = 141490;
}
else
{
this.BackColor = 3329330;
}
return true;
}
application.formTypes('134').items('60').on('After_LOST_FOCUS',
LostFocusCallBack);
The following example script is bound to form 140, which corresponds to the Delivery window in SAP Business
One. After opening the Delivery window, the script automatically opens another window, which contains the
following UI controls:
• Text field and label
• Dropdown list and label
• OK and Cancel buttons
oCreationParams.BorderStyle = 4;
oCreationParams.UniqueID = "MySimpleForm";
//*****************************************
// Add items to the form
// and set their properties
//*****************************************
//**********************
// Add an OK button
//*********************
oButton.Caption = "Ok";
//************************
// Add a Cancel button
//***********************
oButton = oItem.Specific;
oButton.Caption = "Cancel";
//************************
// Add a Rectangle
//***********************
//***************************
// Add a Static Text item
//***************************
oItem.LinkTo = "EditText1";
//**********************************
// Add another Static Text item
//**********************************
oItem.LinkTo = "ComboBox1";
oStaticText = oItem.Specific;
//*************************
// Add a Text Edit item
//*************************
oEditText = oItem.Specific;
// bind the text edit item to the defined used data source
var dBind = oEditText.DataBind;
dBind.SetBound( true, "", "EditSource" );
//*************************
// Add a Combo Box item
//*************************
oItem.DisplayDesc = false;
oComboBox = oItem.Specific;
// bind the Combo Box item to the defined used data source
dBind = oComboBox.DataBind;
dBind.SetBound( true, "", "CombSource" );
oForm.Visible = true;