Hello,
Your post refers to three separate items:
* using Functions in uPlan;
* doing loops in a Plan;
* retrieving data from previous/next recipient.
A. Using Functions in uPlan
===========================
QLingo, VBScript or JavaScript functions calls by an ADOR or a plan
variable are as simple as this:
1. Define your function name (e.g.: myFunc), with the appropriate data
type (string, numeric, date, boolean)
2. Define as many parameters as needed; name each of them (e.g.:
myParam1, myParam2); assign them their appropriate data type;
3. In your QLingo, VBScript or JavaScript function "body":
3a. use your parameter by simply mentioning their names (e.g.:
myParam1, myParam2); current limitation: it is not possible to drag-&-
drop the parameters into the function body; but manually coding the
parameter names - while avoiding typo ;-) - obviously works fine.
3b. In VBScript or JavaScript, define and use as many local variables
as needed (e.g: myVara, myVarb, etc.)
4. To set the return value:
4a. In your VBScript or JavaScript function "body", assign the
function result with the "equal" operator (e.g.: myFunc = myVara)
4b. In your QLingo function "body", just return the calculated value
(e.g.: SubString(myParam1, myParam2, 100)).
5. In your ADOR or variable QLingo code , just call the function, by
mentioning its name and providing the appropriate values for the
expected parameters (e.g.: myFunc(|->[myField], "xxx"))
B. Doing loops in a plan
========================
I would create VBScript or JavaScript functions, which can simply
implement loops.
QLingo does not simply (as "For" or "While" keywords do not exist).
C. Retrieving data from previous/next recipient
===============================================
If your data source can be sorted (which is fairly easy, as soon as
you process it through a plan filter, which contains an SQL "ORDER BY"
statement), and if your data source has a field, which contains a
sequential numbering of each of your recipients (1, 2, 3, ..., n), it
would also be fairly easy to retrieve data from the current or next
recipient, through a plan User View, and a plan variable:
"Previous" variable: |->[myField] -1
SQL query of the "uv_Previous" User View:
SELECT * FROM [myTable] WHERE [myTable].[myField] = @{Previous}
QLingo code of an ADOR or plan variable using the User View:
if (|->[myData]) = [uv_Previous].[myData])
xxx
else
yyy