Tagged with operations - Visokio Forums http://forums.visokio.com/discussions/tagged/operations/feed.rss Mon, 30 Oct 17 18:44:13 -0400 Tagged with operations - Visokio Forums en-CA DataManager: "Custom Script" Operation (2.8+) http://forums.visokio.com/discussion/1657/datamanager-custom-script-operation-2.8- Tue, 17 Jul 2012 08:36:04 -0400 steve 1657@/discussions
The "Custom Script" operation allows you to execute arbitrary Javascript to transform one or more inputs into a new output.

The result of the Javascript must be a two-dimensional array, indexed as [column][row] (i.e. [field][record]). You can optionally choose to provide the field name as the first row in this 'table'.

The inputs are accessible via "input1", "input2", etc. and also via "inputs[0]", "inputs[1]". These objects provide access to all regular Omniscope Javascript functions, such as:


input1.recordCount()
input[0].subset_sum("Price")


Here is an example script which simply ignores inputs, and produces static data:

[
["1, 1", "1, 2", "1, 3"],
["2, 1", "2, 2", "2, 3"],
["3, 1", "3, 2", "3, 3"]
]


Here is another which returns a 2x1 table of metadata about two inputs:

[
[
input1.recordCount()
],
[
input2.recordCount()
]
]


Here is another which does a sideways concatenation of multiple inputs:

working = new Array();
for (i in inputs) {
var input = inputs[i].dataArray(null, null, true);
for (n in input) working.push(input[n]);
}
working;


See attached example. Requires 2.8 or later.]]>