Deploying and Registering a JSSP Service Type

To build your JSSP project, run the NPM build command as shown below. This generates a bundled .js file in the /dist folder, which is the file you use to create a service type in the product.

To build a compact bundled file, execute the command
npm run build
You can use the following command syntax to build a more readable .js file:
npm run build:dev

There are two ways you can register your new custom JSSP service type:

Once the Service Type is registered, you can configure one or more service instances of the new service.

If you change your broker code and update the bundled .js file, you must refresh service instances that use the bundled .js file, and regenerate or update SmartObjects based on the service.

Create From URL

You can use the Create From URL approach to register your JSSP service type when the bundled .js file is located in a URL. For example, use this approach if you want to register a service type based on a .js file that someone else maintains and updates to a central location, or if you are building your own service type and will publish the .js file to a URL. In this case, when you're ready to test your code, copy the latest version of the bundled .js file from the /dist folder to a publicly-accessible location, such as GitHub (use GitHub's Raw view URL if the bundled js file is a project source file).

Once the .js code file is available at a URL, open the Management site and browse to the JavaScript Service Provider SmartObject located at Categories > System > Management > SmartObjects > SmartObjects. Execute the Create method and supply a name, description, and URL, then click OK.

The File URL must be in a location accessible to the environment you are working in.

Create from File

Use the Create From File approach to register your JSSP service type when you do not want to publish your bundled .js file to a URL, but rather want to store the .js file in the K2 database. You will use a SmartForm to deploy your .jssp file to your environment.

When using this approach, you must rename your .js file to a .jssp file, otherwise the file upload will fail. If you used the sample projects provided by the product, you can configure your source to generate your bundled file automatically as a .jssp file by editing the rollup.config.js supporting file

If this is the first time you are deploying any .jssp file, use the Package and Deployment tool to deploy the provided .kspx deployment package to your environment. This package contains the JSSP Connector Form. (If you have not enabled Package and Deployment in your environment yet, see the article How To: Download, Install, and Start Using the Package and Deployment for Nintex K2 Cloud.)

Once you have deployed the JSSP Connector form with the provided package, you can run the JSSP Connector Form located in the JSSP Connector Management folder. Specify a System Name, Display Name and Description, and then upload your .jssp file. Click the Create or Update button. Keep a note of the System Name handy for updating your service type. You will use the same form and the same System Name to update an existing service type with a new version, and remember to refresh any service instances that use the service type to pick up any changes made in the new version.

Using the JSSP Service Type Management Form to upload/update a .jssp file

Considerations when deploying and registering a JSSP Service Type

  • If you want to use the same JSSP Service Type in different environments, you will need to register the Service Type and any Service Instances separately in each environment. The K2 Package and Deployment tool will not deploy JSSP Service Types or Service Instances.
  • The JSSP requires that Service Types have unique System Names
  • If you are using the Create from File approach:
    • The uploaded script file is stored as plain text in the K2 database. Do not include sensitive information such as usernames and passwords in the script file

    • There is a size limit of 5 million characters for the uploaded .js file
  • If you are using the Create from URL approach:
    • Uploading files from some storage providers such as SharePoint or OneDrive for business do not work because of multiple redirects. You can use sites such as Github, pastebin, or Azure Blob storage to host your JS file.
  • Script files are cached for 1 minute by default. It may take a minute for any changes to an updated script file to reflect in the environment.