Database Reference
In-Depth Information
Figure 17-27. The finished Create Invoice Record subscript has almost as many comments as it has
working script steps, yet its task is relatively simple. It makes a new invoice record for a specific
job. But even if you understand the process perfectly, it's fine to leave comments intact. Someone
else who doesn't have your experience may take over the database someday, and your comments
will serve as a tutorial.
Now that the subscript is done, you have to call it from the parent script. You have to pass
the Job ID along to the subscript and then you'll need to grab the subscript's result.
1. In the “Create Invoice for Job” script, set the first Perform Script step under
the Else to run the Create Invoice Record subscript, with a script parameter of
Jobs::Job ID .
You're passing the Job ID to the subscript, so it knows which job it's creating an in-
voice for.
2. Add a Set Variable script step below Perform Script [“Create Invoice Re-
cord”; Parameter: Jobs::Job ID] . Name the variable $invoiceID and then set
its value to Get(ScriptResult) . Save the script .
The subscript will pass the ID for the invoice it's just created back to the main script
so it can create related line items in the next subscripts.
Finishing the Process Timeslips Subscript
Now you tackle the subscript that processes your unbilled timeslips. This script creates a line
item record and puts the Line Item ID into the unbilled timeslip, so it's related to the line
item record and won't be found next time you run the script. (Remember, your Find Unbilled
Activity script looks for all timeslip and expense records that don't have a Line Item ID.)
Then the script grabs the time worked from the record and then loops through the found set
Search WWH ::




Custom Search