Learn Goal 5 - Part 2: Streamline new work orders with a script

Document created by Kedar on Dec 10, 2014Last modified by mark_baum on May 10, 2016
Version 44Show Document
  • View in full screen mode

 

 


We want to make it as easy as possible for the sales team to enter new work orders from their iPads.
In the previous section, you saw how entering them into the bottom row of the Work Orders portal can become cumbersome as the number of work orders increases. Let’s try improving this process using a FileMaker Pro script.

 

Scripts provide a way to automate processes in FileMaker Pro. They consist of one or more actions (called script steps).

 

You create scripts using FileMaker Pro's Script Workspace, which is a special window consisting of three panes. This is what the top of the window looks like:

 

script workspace panes.png

 

 

script workspace left pane.png

 

Scripts pane (left)

 

This pane is for accessing and organizing all the scripts in your solution. This is where you open scripts for editing and one place where you can run them. A progressive search box helps you find scripts quickly once you've created a lot of them. The blue checkbox makes the script available to your users via the Scripts menu at the top of the screen.

 


script workspace center pane.png

 

Script editing pane (center)

 

This pane is for viewing and editing specific scripts. The script you are currently editing is displayed in detail, while tabs across the top of the pane allow you to switch to any other script you have open. You can rename a script by double-clicking on its tab. When you want to focus on the script you are writing, you can hide the left and right panes.

 

 

script workspace right pane.png

 

 

Script Steps pane (right)

 

This pane provides point-and-click functionality for adding steps to your scripts and can also be used as a reference. You can create your own favorites list of the script steps you use the most. If you want to learn more about a specific step, you can view a brief description of it at the bottom of the pane, and click a link to view details in the FileMaker Pro 15 online help.

 

 

 

 

 

 

 

 

 

 

 

 

 

Goal

Make it easier to add new work orders by automating part of the process using a script.

 

 

Steps

  1. Choose the Scripts menu > Script Workspace...  ⇧⌘S or Ctrl-S

    The Script Workspace opens. Because you haven't created any scripts, it looks very empty.
    empty script workspace.png

  2. Click on the + button in the top corner of the window.

    Your new script's name is listed in the left pane. The script itself opens in the center pane, ready for you to start writing it.

    script workspace new script.png
  3. Double-click on the blue bar to change the script name from New Script to Create New Work Order.

    script workspace rename script.png

    Let’s start by adding a Go to Field step that will take the salesperson to the description field inside the portal. This step tells FileMaker Pro which portal you want to work with (on some layouts you might have more than one). To add this step, just double-click it in the script steps list (on the left-hand side of the Edit Script... window).

  4. Type the word field in the progressive search box in the right pane.

    The right pane only displays script steps containing this word.

  5. Double-click the Go to Field script step.

    The script step appears in the center pane as the first step of your script.

    A popover dialog appears giving the script step options.


  6. Select the Go to target field checkbox (in the lower-right of the window).

    A Specify Field dialog box appears. At the top there is a drop-down allowing you to choose a table occurrence.
    adding the go to field step.png
  7. Change the drop-down from “Customers” to “Work Orders”.

    The list of fields changes, showing the fields in the Work Orders table (rather than the Customers table).

  8. Select the “Description” field from the list.

  9. Click the OK button.

    The Specify Field dialog box disappears, and your script step displays the name of the field that you chose (“Work Orders::Description”).



    Next let’s add a step that goes directly to the bottom portal row. This is the main reason for the script: it addresses the pain point of having to scroll manually through many work orders to reach the bottom record.

  10. Add a Go to Portal Row script step from the right pane.

    A popover appears giving the script step options.
    add go to portal row step.png
  11. Change the Specify drop-down from “First” to “Last”.

    This change instructs FileMaker Pro to jump to the last row in your Work Orders portal, saving you the time of scrolling to it.



    But because the bottom row will already contain data and you don't want to overwrite that data you'll need another Go To Portal Row step going to the "Next" row. Since the next row doesn't exist, FileMaker Pro creates it for you automatically.

  12. Repeat steps 10 and 11 for another script step, but this time set the Specify drop-down to "Next".


    Now let’s add a script step that automatically populates the Date field with today’s date.

  13. Add a Set Field script step.

    Again, notice the new Script Step Options that are specific to this step.

    adding the set field step.png
  14. Select the Specify target field checkbox (in the lower-right of the window).

    A Specify Field dialog box appears.

    At the top there is a drop-down allowing you to choose a table occurrence.

  15. Change the drop-down from “Customers” to “Work Orders”.
    specify field.png

    The list of fields changes, showing the fields in the Work Orders table (rather than the Customers table).

  16. Select the Date field from the list.

  17. Click the OK button.

    The Specify Field dialog box disappears, and your script step displays the name of the field that you chose (“Work Orders::Date”).


    Now that you’ve specified the field whose value is changed, let’s specify what information we’re going to put into the field. For this, we’re going to change the “Calculated Result” for the script step.


  18. Click the Specify button next to the Calculated Result label (lower-right hand corner of the screen).

    A Specify Calculation
    dialog box appears, with a blinking insertion point indicating that FileMaker Pro wants to you enter some information.


  19. Type the following expression into the box:  get(CurrentDate)
    calc get current date.png

    This is an example of a FileMaker Pro function, that is, a predefined formula that performs a specific calculation and returns a result. FileMaker Pro provides many built-in functions and you can create custom functions as well. What matters right now is that this specific function always returns today’s date.

  20. Click the OK button.

    The Specify Calculation dialog box disappears, and your script step is updated to include the text that you entered.


    Remember the first step, which takes the salesperson to the description field inside the portal? It needs to be repeated at the end of the script in order to make the description field active so that the salesperson can type into it.

  21. Go back and select the first script step (Go to Field…).

  22. Press Command-D (OS X) or Control+D (Windows).

    The script step is duplicated.


  23. Drag the duplicated step to the end of the script.

    The finished script should look like this (with added comments). Note how special colors help you read the script more easily: green for comments and pink for field names.
    create new work order script.png

    You’re done! You only need these five script steps. The salesperson will complete the rest of the process manually.


    Let’s close the Script Workspace and save the script.

  24. Click the red X button in the upper left of the Script Workspace window.

    A dialog box appears, asking whether you want to save your script first.
    save script confirmation.png

  25. Click the Save All button.

    The dialog box disappears and the Script Workspace window closes as well.

 

That’s it — the script is saved and ready to go. Now you just need to make it available to the sales team.

 

     

      

Attachments

    Outcomes