Exercise #4 – Scripting and Dispatch Panel tips


This exercise builds on the previous three. You can see Exercise 1 here, Exercise 2 here, and Exercise 3 here.

Note: the result this script provides, has been replaced by the automation features > automatic dispatch. The guide is still useful in providing an example on how scripting capabilities can be used with Dispatch.


Scripts can automate many dispatching processes, which means fewer chances for human error and large time savings. Today, we’ll create and test a timer script that dispatches all planned jobs. Businesses could use this to automate the dispatching of jobs to their mobile workforce early each morning.


Enable the following permissions in your application properties:

  • Events > _EditScriptExpression
  • Login > _WebServiceScriptLogin
  • All permissions in the ScriptApp folder
  • All permissions in the Plugins > Dispatch folder

Create an Event Script

Log in to the same Vehicle Tracker application you used for Exercise 1-3 as an admin user.

Pre-work: Create a few jobs with worker = Exercise1Worker (your worker from our first exercise) and date = today. These should show with state = Planned. Our script will allow you to automatically dispatch them.

1. Go to Admin > Development > App Builder.


2. Click + App.

3. Name your app and choose the roles with access to it.


4. In 2. Click Scripts, click + Click Script.


5. Name the click script, and select Timer in the Kind menu. For Next Execution, select an earlier time today (e.g. 4:00am with today’s date), and enter a schedule if you would like.


6. Click Edit next to Script.

7. Paste in the javascript below, replacing the current text in the editor.

var users = directory.getUsers();
var jobs;
var routes;
if (users != null) {
 for (var i = 0; i < users.length; i++) {
      jobs = dispatch.getPlannedJobs(users<i>.id, new Date());
      for (var j = 0; j < jobs.length; j++) {
      routes = dispatch.getPlannedRoutes(users<i>.id, new Date());
      for (var j = 0; j < routes.length; j++) {

8. Test the script by clicking > Run Script and then click Save.


9. Click Save again on the Edit App page.


Your timer click script is now complete.  You will now see your saved script in the App Builder window. You should also see that the jobs for Exercise1Worker now show in yellow with state = Dispatched. If you are logged in to the Dispatch mobile app with your Exercise1Worker, you will also receive job notifications. 


Dispatch Panel

The Dispatch panel allows you to see much more than just the list of workers and their job/route status.

  • See job locations for each worker at glance.
  • Drill into a worker to see details about their routes and jobs for the day.

The worker detail popup window is fully responsive. Be sure to try resizing the window and choosing the data columns to customize your workspace. Let’s click around to see some new Dispatch panel functionality.

Job Locations at a Glance

Click on the pin icon on the right-hand side of a field worker row to see the location of all of their jobs. This works for jobs with worker Unassigned, and also for those currently assigned or dispatched to a worker. 


Work / Job List Drill down

For routes with lots of stops, or an abundance of jobs for a particular day, you may want to see many more jobs at a glance than via the Dispatch Panel rows.

    • Click the hamburger icon on the right-hand side of a field worker row to see a full job list for the field worker. You can also do this in the Unassigned jobs row.


  • Right-click the header row in the new window to customize the columns shown.
  • Change the column width by hovering your mouse on the column border until your cursor shows arrows. Click when the arrows are showing and drag to resize a column.
  • Use the Resize to fit and the Force fit columns menu options to have the system auto-select column widths for you based on the window width.


  • Change the window size by using the drag feature in the bottom right corner of the window to resize.
  • Print a full job list with your chosen columns.