Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AL Prolog and script connector

67 views
Skip to first unread message

John Guy

unread,
Apr 1, 2015, 4:31:21 PM4/1/15
to
I think I might be missing something obvious here:

If I set a variable in the AL's Prolog - Before Init hook and then try to reference it in the script of the script connector (the initialization function or otherwise), I get an exception that the variable could not be found.

Prolog - Before Init:

var counter = 0;

Script connector script:

function selectEntries() {
task.logmsg("the counter is " + counter);
counter++;
}

CTGDIS495I handleException , get, java.lang.Exception: 'counter' not found

I can move the code into the initialize function, but I could not find this behavior documented anywhere.

Eddie Hartman

unread,
Apr 2, 2015, 1:41:06 PM4/2/15
to
Normally any variable you define anywhere in an AL (except when using 'var' in a function body) is available everywhere else in that AL. This is because Javascript has global variables, and the entire AL has a single instance of the Javascript Engine.

The exception is scripted components, where each scripted component has its own Script Engine instance. As such, there is no sharing of variables between the AL and its scripted components.

So you pass data via Input/Output Maps, as well as setting parameters. And note that you can set any parameter value - it does not have to be a 'valid' one that is exposed in the Connection tab. This is another way to pass info between AL and scripted component.

A third option is via the properties of the JVM itself:

java.lang.System.getProperties().set(key, value)

where the 'value' can be any type of Java object, like an Entry or even a Javascript object.

Hope this helps!
0 new messages