Click Script: Auto-switch between business and off-hours trips

Sometimes fleet vehicles will not only be used in business but can also be driven on private trips. For privacy reasons, private trips should not be tracked or recorded in the system. For example, the vehicle will run for business from 8:00 AM to 5:00 PM and outside that period, all trips should be considered private ones. How can the system automate switching between business and personal time?

With GpsGate, there a few ways to switch vehicles between business and personal (i.e. tracking vehicles or not tracking them), depending on the use case. If personal use of vehicles is not common, you may want to handle this manually. If the fleet is routinely used outside of business hours for personal travel, an automation is possible. 

In both cases, we are changing the "Position Source" option for the vehicle(s) to disable/enable the vehicle's position on the system. That allows for lots of privacy customization. If you are only switching it for one or two users, it is easy to do this manually. For habitual use or for larger fleets, you may want to automate this. Let's go through both options.

 

Manually setting trip privacy with the user type editor

Click here to learn how to use the User Type Editor to enable position source or ignore the vehicle position. 

Screenshot_2021-04-14_at_14.24.11.png

With larger fleets, this can be time-consuming work. It's hard to switch vehicles at the end of the day during a small window of time. The operator would need to edit them one by one manually. Let's learn how to automate it!

 

Automating business & off-hours trip privacy

You can use a click script to automate this task. The timer click script works to switch the trips automatically. 

First, we will create an App called “Switch Business and Private” and assign it _Administrator role.

Screenshot_2021-04-14_at_13.49.32.png

Now add two Click Scripts named "SwitchToBusiness" and "SwitchToPrivate." Choose the Timer kind, and specify the time of the first run. If hours/minutes/seconds fields are left at 0, this script will run once per day at the specified time.

Screenshot_2021-04-14_at_13.49.38.png

Screenshot_2021-04-14_at_14.22.07.png

Add the script as below: Set false for "SwitchToBusiness" and true for "SwitchToPrivate".  

// Script for Timer actions.

// Get User Tag by Name
var tag = tags.getTagByName('Test_Tag');

// Get users under the Tag
var users = tag.userIDs;

for(var i in users)
{
var u = directory.getUserByID(users[i]);
// Set true to disable the position and false to enable the position.
u.setHidePosition(true);

log("Switch " + u.username +" to Business")
}
log("OK");

 

Then the script will run at the time which you set to switch the business and private trip. 

Screenshot_2021-04-14_at_14.32.28.png