Database Reference
In-Depth Information
meters aren't passed to subscripts, that doesn't help Find Unbilled Activity do its work. So
you have to pass the Job ID to the subscript when it's run. You do that in the Perform
Script step.
1. In the Manage Scripts window, double-click the “Create Invoice for Job” script
to edit it. Select the first Perform Script [<unknown>] step .
The Script Step Options area shows a Specify button.
2. Click Specify. Select the Find Unbilled Activity script. In the “Optional script
parameter” box, type Jobs::Job ID . Click OK to return to the Edit Script dialog
box .
If you don't like typing field names, click Edit instead and then add the field in the
Specify Calculation window. Then, close the Specify Calculation window by clicking
OK. Leave the script itself open, though. You've still got information to pass along in
the next tutorial.
You've passed the Job ID to the Find Unbilled Items subscript to use as it runs. In turn, that
subscript passes the $invoiceID back to the “Create Invoice for Job” script. The next two
subscripts will need that value when they create line items to attach to the new invoice.
Checking a Subscript's Result
When you run a subscript, the main script often needs to know what happened when the sub-
script was run. That's why the Find Unbilled Items subscript set a script result as its last step
( Exit Script (Result) ). But just as script parameters aren't passed to subscripts unless
you specifically pass them in their Perform Script step, you have to explicitly ask for the
subscript's result so you can use it in the calling script. In this case, you'll put the subscript's
result into a variable and then test the variable's contents in the If step you created back on
Considering Exceptions .
1. Add a Set Variable step below the first Perform Script set. Name the variable
$unbilledItems , and set its value to Get(ScriptResult) .
This step completes the job of passing the variable's value from the subscript up to the
main script.
2. Double-click the If test to edit it. Set its calculation to $unbilledItems = 0 .
This tells the script to test the count of found items made by the subscript.
3. Save your script .
Search WWH ::




Custom Search