Create a script for a transform definition

Create the script at any time during the configuration of a definition.

About this task

The script can perform a transform action without using a variable, but the action of the definition will be the same for all fields. Variables create more flexibility for the definition, enabling an administrator to use the same definition in different ways in different places. If a variable is defined, the script must reference the variable using the correct format.

There are three arguments in the script:

  • Variables: Contains the variables using the format variables.<variable name>.
  • Value: Contains the un-transformed value
  • Parameters: Special objects that set debug messages.

Procedure

  1. Open the Odd/Even record in the Transform Definitions module.
  2. Enter the following script to pass values with the odd_even variable.
    function(variables, value, parameters) {
    	var odd = ('odd' == variables.odd_even);
    	var val = value - 0;
    	var val_odd = ((val & 1) == 1);
    	if (odd != val_odd)
    		val++;
    	return '' + val;
    	}

    Notice that the script references the variable in the form variables.odd_even.

    Column named referenced in variable
  3. Update the record to complete the configuration.

    The Odd/Even transform definition is now ready to use in a field transformation.