Discussion:
QQ About global scope variables
Add Reply
Cristian Ares
2018-01-11 14:24:40 UTC
Reply
Permalink
Raw Message
Hi There,

I know its a newbie question, but I'm smashing my head on this simple concept, that I've been reading and re-reading over and over again.

How exactly is possible to set a global variable with a value from a hook (like after lookup) or from a script connector?.

The mostly easy explanation i found from Eddie is this one:
http://www.tdi-users.org/foswiki/Integrator/ScopingOfVariables

But still, if i do this:

var entry = system.newEntry();
entry.setAttribute ("name", "value");

or

work.setAttribute ("name", "value");

i cannot call it later as work.name in other connectors that follow of the AL.

i still cannot grasp the concept of this when dealing with script connectors or hooks. up until now i found ways to avoid this, but now i need to set a global variable in a hook an i'm at a loss understanding the concept.

Any thoughts on this?

FYI the link for the flow diagrams that i found since the new KC are broken, here's the flow diagram from IBM's FTP: ftp://public.dhe.ibm.com/software/security/products/SDI/docs/610/tdi610_flowdiagrams.pdf

Thanks!
Enio Padilla
2018-01-11 17:21:38 UTC
Reply
Permalink
Raw Message
You can initialize a variable value in the Global After Initialize hook, and you can use that variable in any hook and it will hold the value through the AL execution.

i.e.

in after initialize hook:

var counter = 0;

In your other hook:

counter++;
Cristian Ares
2018-01-11 17:32:05 UTC
Reply
Permalink
Raw Message
Post by Enio Padilla
You can initialize a variable value in the Global After Initialize hook, and you can use that variable in any hook and it will hold the value through the AL execution.
i.e.
var counter = 0;
counter++;
Hi Enio, i forgot about the prolog and epilog hooks, that did the trick, i never though about using those hooks, thanks!!
Loading...