The JavaScript library also supports calling SAP function modules and BAPIs in Nintex Forms.
In this example, a customer name is entered in an input field and the possible hits are displayed in a dropdown-list. If a customer master record is selected in the dopdown-list, the customer number is displayed in a separate field.
The request to the SAP system to retrieve the customer data is made by calling a function module (SD_RFC_CUSTOMER_GET).
Step 1: Define text fields
In the Nintex form we need three fields:
The first field Customer Name of type Single Line Textbox is the input field and contains the customer name.
In the second field Select Customer of type Choice, the possible hits for the entered customer name are displayed in a drop-down list and can be selected.
The third field Customer Number of type Single Line Textbox displays the customer number.
Proceed as shown in the previous example Load data in dropdown-lists.
Set field_output_id as Client ID JavaScript variable name for field Customer Number.
Step 2: Insert JavaScript code
Add a reference to our JavaScript library under Form Settings -> Advanced -> Custom JavaScript Includes:
Insert the JavaScript code under Form Settings -> Advanced -> Custom JavaScript.
The function tEcs.executeFunction is called in the code to read the customer information with the SAP function module SD_RFC_CUSTOMER_GET. The input parameter is the field NAME1, the return is processed using the table CUSTOMER_T:
Step 3: Execute the Nintex form
Execute the form and enter a customer name. The hits for the entry are read from SAP and displayed in the dropdown list (Select Customer).
If you select a customer from the list, the customer number is displayed in the Customer Number field.