Database Reference
In-Depth Information
of unbilled timeslips and adds the time worked from each record. After the last timeslip re-
cord is processed, the script puts the time value in the line item record.
Most steps are variations on what you've been doing—switching layouts, doing If tests, cre-
ating records, and setting data into records from variables. Working through a found set of
records requires a new scripting tool: the loop. To get ready to adapt your script to a loop,
open the Process Timeslips subscript and then use Figure 17-28 to prepare the basic process
in your script.
Figure 17-28. The Process Timeslips subscript goes to the Timeslips layout to see if the Find Un-
billed Items subscript found any records. If the found count contains records, the script switches to
the Line Items layout and makes a new record with the Invoice ID that's passed via the subscript's
parameter. Finally, it puts the new line item's ID in a variable so that you can put the ID into each
timeslip record.
Creating a Looping Script
A loop runs a set of script steps over and over again. There's an art to getting the right set of
steps between the Loop and End Loop steps. Most times, you have to do a little prep work to
get the database ready to enter the loop. Then inside the loop you put the steps that are re-
peated once for each record. And you must always have a way for the loop to stop. In this
case, since you're working on a found set of records, you'll use a Go to Record step that
exits after the last record. Here's how to create a loop in the Process Timeslips subscript:
1. Add a Go to Layout step below the Set Variable step. Specify Timeslips for the
target layout .
The script was just on the Line Items layout, so you need to make sure the loop will
happen in the proper context.
Search WWH ::




Custom Search