Configure a function to produce the needed result.
With a function configuration window open:
1. Provide the following details:
- Function Name - The function name.
- Description - A description for the function.
- Input Fields - Acts as the input fields for the function. Source schema fields connected to this function can be selected as the input source under "Source Data Field". You may have up to a maximum of 10 input fields. "xmlJsonConverter" and Javascript reserved words are not valid Input field names.
Note: All fields are required except for the Description.
2. In the text area labeled "Function", write Javascript to transform the incoming data.
- Input data are stored in variables corresponding to the Input Fields given in the step above.
- The output value of the function should be stored in a variable named result.
- An XML converter library (xml-js) is available for use inside the function, and is referred to by using the identifier xmlJsonConverter. The official library function documentations provide in-depth explanations and examples.
Basic Example:
A function has a single input named "numberInput", and the function increments incoming data by 1.
let result = numberInput + 1;
XML <-> JSON Conversion Examples:
JSON to XML conversion, where the input containing JSON is named "jsonValue":
let options = {compact:true,ignoreComment:true,spaces:4};
let result = xmlJsonConverter.json2xml(jsonValue,options);
XML to JSON conversion, where the input containing XML is named "xmlValue":
let options = {compact:false,ignoreComment:true,spaces:4};
let result = xmlJsonConverter.xml2json(xmlValue,options);
Note: The data type of the "result" variable should either: a.) match the data type of the target field the function is connected to; or b.) be supported by the data type conversion matrix below.
Allowed Data Type Conversions
|
Destination data type |
string |
number |
boolean |
array |
date |
object |
mixed |
Source |
|
|
|
|
|
|
|
|
string |
|
yes |
|
|
|
|
|
|
number |
|
yes |
yes |
|
|
|
|
yes |
boolean |
|
yes |
|
yes |
|
|
|
yes |
array |
|
|
|
|
yes |
|
|
yes |
date |
|
yes |
|
|
|
yes |
|
yes |
object |
|
|
|
|
|
|
yes |
yes |
mixed |
|
|
|
|
|
|
|
yes |
3. Click the "Update Function" button to finalize the configuration.
Comments
0 comments
Please sign in to leave a comment.