Hi! The standard way to share data among Activities in WF is the Mapping
Activity. We can save data into the "flowdata" object using "Target
Expression" and "Source Expression" columns. Then in order to access a
variable it is needed to call the flowdata.get('var_path') function.
There are some limitations I experienced using this way:
1. If we create two variables in the same Mapping Activities then it is
not possible to reference each other in the scope of its Mapping
Activity. It is possible to get the variable at least at the -next-
Activity.
2. It isn't easy to pass/get an array of data among variables. In order
to get array one should use "xml node" functions to get an array of data
(as I remember).

But there is another way to share data in the WF. It is using just
variables.
1. If two "flowdata" variables are declared in the same Mapping Activity
then we can share JS variables among this "flowdata" variables.
For example, there are two "flowdata" variables in the same Mapping
activity:
1)flowdata.VAR/a

Source Expression:

Code:
--------------------
var b = [10, 11];

(function () {
return "A";
})()
--------------------


2) flowdata.VAR/b
Source Expression:

Code:
--------------------
b
--------------------

Here we share variable "b" among "flowdata" variables in the scope of
the same Mapping Activity.

Then if we add as a next Activity a "log" Activity, for instance, we can
access "flowdata" variables as well as JS variables:

Code:
--------------------
java.lang.System.out.println("### flowdata.get(VAR/a): " + flowdata.get('VAR/a'));
java.lang.System.out.println("### flowdata.get(VAR/b): " + flowdata.get('VAR/b'));

java.lang.System.out.println("### b: " + b);
java.lang.System.out.println("### toString(b): " + Object.prototype.toString.call(b));
java.lang.System.out.println("### b[0]: " + b[0]);
java.lang.System.out.println("### b.join(,): " + b.join(","));
--------------------

=======
Output is:

Code:
--------------------
2015-03-04 10:03:37,731 INFO [STDOUT] (pool-26-thread-9) ### flowdata.get(VAR/a): A
2015-03-04 10:03:37,731 INFO [STDOUT] (pool-26-thread-9) ### flowdata.get(VAR/b): com.novell.soa.script.mozilla.javascript.NativeArr ay@140504e
2015-03-04 10:03:37,732 INFO [STDOUT] (pool-26-thread-9) ### b: 10,11
2015-03-04 10:03:37,732 INFO [STDOUT] (pool-26-thread-9) ### toString(b): [object Array]
2015-03-04 10:03:37,733 INFO [STDOUT] (pool-26-thread-9) ### b[0]: 10
2015-03-04 10:03:37,733 INFO [STDOUT] (pool-26-thread-9) ### b.join(,): 10,11

--------------------

*My question is Can I rely on the second approach? Is it work as
designed?*


--
hello_amigo
------------------------------------------------------------------------
hello_amigo's Profile: https://forums.netiq.com/member.php?userid=211
View this thread: https://forums.netiq.com/showthread.php?t=52980