• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 8. Working with Conditional Scri... > Using Status Functions with If Steps

Using Status Functions with If Steps

Combining a status function with a conditional step, we can create a script that automatically adds the current date to an invoice, calculates the net 30 date when it will become overdue, then prints the invoice. Before you create the script, remember to set the Print/Page Setup options for the invoice.

To date and print an invoice using status functions:

Choose Scripts > ScriptMaker.

When the Define Scripts dialog box appears (Figure 8.15), type a name for the script (in this case Print Invoice) and click Create.

Figure 8.15. Script names should indicate what the script will do.

The Script Definition dialog box will appear with the default script in the assembly window on the right. Click Clear All to delete the default steps.

From the Control category in the left window, double-click If.

In the Options section, click Specify to bring up the Specify Calculation dialog box. In the function list on the right, double-click the IsEmpty function (Figure 8.16).

Figure 8.16. IsEmpty checks for data in a field.

IsEmpty checks whatever field you put in the parentheses to see if there is data in it.

From the field list on the left, double-click Invoice Date. Click OK to close Specify Calculation.

This section of the script checks the Invoice Data field to see if you have already entered anything in it (Figure 8.17).

Figure 8.17. IsEmpty checks to see if the record has an Invoice Date.

In the Script Definition dialog box, scroll down to the Field category in the left window and double-click Set Field.

In Options, click the Specify check box.

When the Specify Field dialog box appears, choose the same field name you used in the If step. Click OK (Figure 8.18).

Figure 8.18. The fields in IsEmpty and the Set Field step must match.

In Options, click the Field (Windows)/Specify Field (Mac) button.

When the Specify Calculation window appears, click the View drop-down menu and scroll down to choose Status Functions (Figure 8.19).

Figure 8.19. The View drop-down list lets you choose functions by category.

From the list of Status functions, double-click on Status(CurrentDate) (Figure 8.20). Click OK.

Figure 8.20. The Status(CurrentDate) function returns the computer's current date.

This portion of the script will check the computer's settings and enter the current date in the Invoice Date field.

The Set Field step in the script assembly window should be highlighted. Click the Duplicate button. A copy of the step appears below the original (Figure 8.21).

Figure 8.21. Since this step is almost the same as the previous, duplicating it is easier than creating it.

We need to edit this step so that it will check the status of a different field. In Options, click the Field button (Figure 8.22).

Figure 8.22. Click the Field button to edit a field you've previously specified.

When the Specify Field dialog box appears, choose the field name (in our example, we choose Overdue Date). Click OK (Figure 8.23).

Figure 8.23. The duplicated step needs to have a new field chosen.

The second Set Field step now looks at a different field.

In Options, click the Specify button.

When the Specify Calculation window appears, click inside the formula box just after Status(CurrentDate) and type +30 (Figure 8.24). Click OK.

Figure 8.24. The Overdue Date field is set to thirty days after the Current Date.

This script line (Figure 8.25) checks the status of the current date, adds thirty days to it, and inserts that date into the Overdue Date field.

Figure 8.25. The duplicated and edited Set Field step.

In the script assembly window, click to select the End If step.

Scroll down to the Navigation category in the left window and double-click Go to Layout (Figure 8.26).

Figure 8.26. Select End If to add Go to Layout to the end of the script.

In the Options section, choose Invoice from the Specify drop-down list (Figure 8.27).

Figure 8.27. The script switches to the Invoice layout before printing.

This step switches the mode from its current status to Layout, and chooses the Invoice layout.

Scroll down to the Sort/Find/Print category in the left window and double-click Print (Windows)/Page (Mac) Setup.

Leave the options checked (Figure 8.28).

Figure 8.28. The Restore option will ensure that the invoice prints using the correct Page/Print Setup.

In the left step window, double-click on Print.

In the left step window in the Navigation section, double-click on Go to Layout. Leave Specify set to “original layout” (Figure 8.29).

Figure 8.29. The last step in this script will return you to the layout where the script started.

This last part of the script returns you to the original layout.

Click OK, then Done.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint