How to use Custom Fields with Event Rules

Using this method you will allow your application users to select their Notifications preferences for their vehicles' Event Rules. This is specially useful in a restricted environment with users with limited roles. You as an administrator will save time with fewer user's modification requests. The users can do it by themselves in a very intuitive way by just modifying the Vehicle properties and select the values in the GUI. In our example we will create a combo box (Custom Field) that is going to be available in the Vehicle Properties (User Access Mask) where the user can select and save which notification type he wants for a Speeding Alert for that vehicle. The Speed Limit value is also a property that the user can set to each vehicle and will define the execution of the Event Rule.


  1. Add the Custom Fields
  2. Modify the User Type
  3. Create a new User Access Mask
  4. Create a new role and assign the Access Mask
  5. Create your Event Rules with the script
  6. Testing

Add the Custom Fields

In your application properties add the following privilege in Privileges and Features_EditCustomField

We have to select the Custom Field list and put here all the different notifications that our Event Rules will handle. We have to remember what we have typed in the Item and Value columns because we will call them later in our scripts.

We also want to add another Custom Field called Speed Limit of the type Text

Modify the User Type

Now that we have these Custom Fields set we need to add them to our Vehicles’ properties. To simplify this task we will modify the Device User Type in the User Type Editor.

We select User Type Device and then we will add our new Custom Fields created previously, under Details

If we edit a Vehicle we can see now the two added Custom Fields

Create a new User Access Mask

If we want to limit the amount of information that a user is able to modify or have access to, we need to create User Access Masks. You can read how to setup a user mask here.

We will create a new User Mask so we will find the menu in the Vehicle panel. Enable in your application Privileges and Features the privilege _UseUserAccessMask.

Add the privilegies User Type and the two new Custom Fields we created before. You can add as many other fields you consider necessary according to your customer’s needs.

Create a new role and assign the Access Mask

The idea is to assign a user (for example an Operator) a limited scope for editing User properties. We already created the Mask but we didn’t apply it yet to our User. We will create a new Role, assign the new Mask to that role and later assign this Role to the user/operator.

Go to Admin -> Roles and select Create copy

We can directly assign here the user/s that will make use of this role.

This is the important part where we choose this role to make use of the User Access Mask created previously

Create your Event Rules with the script

Now we have to create our Event Rules for each notification we pretend to send. As we created three different choices (the Disabled option is not going to generate any event) for our notifications (Email, SMS, Marker) we will need three Event Rules as shown in the image:

The first step is to enable the privilege _EditScriptExpression in your application Privileges and Features.

When creating your Event Rule in the step 4. Expressions you have to select Script Expression.

For this example we will input a simple Javascript code that will compare the Speed Limit value from the vehicle properties and it will return true activating the Rule if matches the condition.

A script for the Email notification could be like this:

var notifType = session.user.getCustomFieldValue ('Speeding Alert'); //from the Vehicle properties
var limit = session.user.getCustomFieldValue ('Speed Limit'); //from the Vehicle properties
var speed = fields.get('Speed', null)*3.6; //current Vehicle speed with mt/s to Km/h conversion
if(notifType == 'Email' && speed > limit) return true;
// else
return false;


    • Remember that the values that you are using in the function getCustomFieldValue and the comparison values inside the IF clause should mach the values and Custom Fields labels you’ve setup in the creation of the Custom Fields


The SMS and Marker scripts change slightly. In the following images we highlight the changes:


Marker on map


Connect to the Vehicle Tracker application with your Operator that you had assigned the new Role (see ‘Create a new role and assign the Access Mask’)

Edit your Vehicle/Unit

Insert the values for Speed Limit and select a Notification method

Use SimOne to make your tests. In our example the Event Rule Speeding Alert - Marker has been activated when the speed is higher than the limit set for that vehicle.