Skip to main content

Parameter parsing for scripts

Create script and Update script commands evaluate parser parameters from a Cloud Code script.

In the example Script.js, one parameter with name range and type NUMERIC is parsed and uploaded to UGS.

For more details, check Declare parameters in the script.

Parsing limitations

Create script and Update script evaluate the given Cloud Code script to parse the parameters. As a result, these commands cannot parse parameters if you declare them at the beginning and overwrite/delete them after.

For example, this script is problematic:

const _ = require("lodash-4.17");

const NUMBER_OF_SIDES = 6;

module.exports.params = {
sides: "NUMERIC"
};

module.exports = async ({ params, context, logger }) => {
// ...
};

// Functions can exist outside of the script wrapper
function rollDice(sides) {
return _.random(1, sides);
}

The script defines module.exports.params at the beginning, but then it is overwritten by module.exports = async ..., so Create script or Update script cannot parse the parameters.