The following article shows how to synchronize a Nintex form for Office 365 with SAP using custom JavaScript.
In the depicted scenario, SAP data is made available in a Nintex form for data selection in dropdown lists using JavaScript and REST services.

For more information on Nintex form for Office 365, see Nintex Documentation: Office 365 Forms.

About #

This article leads you through all necessary steps to set up the following process in Nintex for Office 365:

  • When an SAP material number is entered in an input field, the possible hits are displayed in a dropdown list.
  • If a material is selected in the drop-down list, the material text is displayed in a text field.
  • When the input is confirmed, the selected material is written to SharePoint.

Setup in yunIO #

yunIO is the connector that reads and writes data from and to SAP. For more information on yunIO, see Theobald Software: yunIO.

  1. Define a connection to your SAP system in yunIO.
  2. Create a new service in yunIO. The depicted example uses the integration type SAP Table or View for the service.
  3. Look up the table MAKT that contains material descriptions.
  4. Select the columns MATNR, SPRAS and MAKTX for the output of the service.
    nintex-office-design
  5. Click run to testrun the service in yunIO (1). For more information, see Online Help: Testing a Service.
  6. Click download-file to download the service definition (2).
    yunio-Services-Function-Download

Setup in SharePoint #

In the depicted example, SAP materials are added to a custom SharePoint list via a Nintex form:

  1. Create a SharePoint custom list with a column “Material”.
    nintex-sharepoint
  2. Click [Nintex Forms] to create a new Nintex input form for the SharePoint custom list, see Setup in Nintex for Office 365.

Setup in Nintex for Office 365 #

Follow the steps below to set up the Nintex form for the SharePoint custom list created in the section Setup in SharePoint:

  1. Create a new Nintex form:
    nintex-office-design
  2. Define the following text fields:
    • “Material” of type Single Line Textbox is the input field that contains the material number.
    • “Suggested Materials” of type Choice displays the possible hits for the material number in a dropdown list.
    • “Selected Material” of type Single Line Textbox displays the material text of the selected material.
  3. Open the advanced settings of the field “Material” and set Store Client ID in JavaScript Variable to Yes.
  4. In the field Client ID JavaScript variable name enter the variable name “inputMaterial”.
    nintex-office-material-number
  5. Click [Save].
  6. Open the general settings of the field “Suggested Materials” and set Display format to Drop down list.
  7. In the field Choices enter “no matches”. This input will be overwritten via JavaScript.
  8. Open the advanced settings of the field “Suggested Materials” and set Store Client ID in JavaScript Variable to Yes.
  9. In the field Client ID JavaScript variable name enter the variable name “selectMaterial”.
    nintex-office-dropdown
  10. Click [Save].
  11. Open the general settings of the field “Selected Material” and set Connected to to the SharePoint column Material.
  12. Open the advanced settings of the field “Selected Material” and set Store Client ID in JavaScript Variable to Yes.
  13. In the field Client ID JavaScript variable name enter the variable name “outputMaterialId”.
    nintex-office-output
  14. Add a [Save] and [Cancel] button to the form.

Integrating JavaScript Code in Nintex #

The JavaScript library for REST services by Theobald Software enables the use of yunIO services via JavaScript.
The depicted example uses the following JavaScript code for the following:

  • To import the JavaScript library for REST services.
  • To connect to yunIO.
  • To run the service “MAKTService” that reads the material number and the material long text from the SAP table MAKT.
document.addEventListener("DOMContentLoaded", async () => {
    let yunioClient = await import(
        "https://static.theobald-software.com/theobald.yunio.client.js/dist/theobald.yunio.client.js"
    );

    yunioClient.TheobaldYunioClient.initializeLiveCombobox({
        $: NWF$,
        controls: {
            inputId: inputMaterial,
            selectId: selectMaterial,
            outputId: outputMaterialId
            /*descriptionId: outputMaterialDescription*/
            /*buttonId: 'buttonId'*/
        },
        tableSettings: {
            serviceName: "MAKTService",
            idField: "MATNR",
            description field: "MAKTX",
            language: "E"
        },
        connection: {
            url: "https://yunio.example.com:8175/",
            /* future apiKey */
            username: prompt("yunIO username", ""),
            password: prompt("yunIO password", "")
        }
    });
});

To use this script in your application, replace the connection URL. If your yunIO service has a different name or settings, edit the table settings accordingly.

Note: Do not use // for comments in the custom java script, as // causes errors.

Follow the steps below to integrate the script in your Nintex Form:

  1. Open the settings of the Nintex form and copy the JavaScript into the field Custom JavaScript. nintex-office-java-code
  2. Click [Save].

Running the Nintex Form #

  1. Preview or publish the Nintex form.
  2. When prompted, enter your username and password to establish a connection to yunIO.
  3. Enter a material number. The hits for the entry are read from SAP and displayed in the dropdown list “Suggested Materials”.
  4. Select a material from the dropdown list. The long text of the selected material is displayed in the field “Material”.
  5. Click [Save] to write the selected material to your SharePoint custom list.
    nintex-form-for-office-365