Visokio website     Downloads     Video tutorials     KnowledgeBase  
DataManager: "Custom Script" Operation (2.8+) - Visokio Forums
DataManager: "Custom Script" Operation (2.8+)
  •     steve July 17, 2012 8:36AM
    Omniscope 2.8 introduces a new operation called "Custom Script".

    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.
  • 2 Comments
  • admin May 10, 2013 11:53AM
    This feature is now publicly available in 2.8 beta:
    http://forums.visokio.com/discussion/2130/omniscope-2.8-beta
  •     richard July 26, 2013 7:28AM
    An example using a Custom Script operation to convert OSGB grid references to OSGB map coordinates:
    http://forums.visokio.com/discussion/comment/8270/#Comment_8270

Welcome!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership