Topic Options
#31263 - 05/06/09 07:54 AM Run Script as a Condition
Lou Pace Offline
OL User

Registered: 01/10/04
Posts: 69
Loc: Bloomfield, New Jersey
Hi,

The online documentation is a bit unclear on how to use a script as a condition. How do you use Script.ReturnValue? Is it similiar to a global function in a form that returns a value (passed back through the variable &result?) Can someone post an example script here?

many thanks,
Lou
_________________________
thanks,
Lou Pace

Top
#31264 - 05/06/09 08:02 AM Re: Run Script as a Condition
Philippe F. Offline
OL Expert

Registered: 09/06/00
Posts: 1931
Loc: Objectif Lune, Montreal, Qc
When the script returns control to the Workflow tool, the Script.ReturnValue variable is examined. It must contain a boolean value (True/False) that instructs the process on whether the condition must branch or not.

For instance, to create a condition that checks for the existence of two files, you could use a script similar to the following:
Code:
Option explicit
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject") 
Script.ReturnValue = fso.FileExists("c:\FirstFile.txt") and fso.FileExists("c:\SecondFile.txt")
The "condition" is therefore True only if both files exist.

Hope that helps.
_________________________
Technical Product Manager
I don't want to achieve immortality through my work; I want to achieve immortality through not dying - Woody Allen

Top
#31265 - 05/06/09 08:27 AM Re: Run Script as a Condition
Lou Pace Offline
OL User

Registered: 01/10/04
Posts: 69
Loc: Bloomfield, New Jersey
Philippe,

We just tried this and it works just as you said. Thanks so much for the quick answer to my post!

Lou
_________________________
thanks,
Lou Pace

Top
#31266 - 05/06/09 11:46 AM Re: Run Script as a Condition
Anonymous
Unregistered


Hi,

Just want to add that I also use it with the 0/1 values and it works. (Script.ReturnValue = 1 will make the workflow enter the true branch of course)

Olivier

Top
#31267 - 05/06/09 12:20 PM Re: Run Script as a Condition
Yannick Fortin Offline
OL Expert

Registered: 08/25/00
Posts: 349
Loc: Objectif Lune Montréal
To clarify, any numeric value other than 0 will be considered to be true. The behavior when assigning a non-numeric or non-boolean value (e.g. a string) is undefined.

This allows this kind of code construct:

Script.ReturnValue = Len(Trim(region(...)))

The Len() function returns the length of a string, or 0 if the string is empty. So this code effectively checks if the specified region is empty of text.
_________________________
Yannick Fortin, Team OL

Top