User avatar
johan
GpsGate
Posts: 14925
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

GUIDE: Script Notifiers

Wed Jun 11, 2014 12:46 pm

GUIDE: Script Notifiers

We are introducing a new and a more flexible way to define event notifiers. Now you can use Script Notifiers to create notifiers using JavaScript and GpsGate Scripting API.

Script Notifiers are a new way to create fully customizable event notifiers using JavaScript language and GpsGate Scripting API. By leveraging this feature, you can make your event rules smarter, simply by handling different states with your own custom code. For instance, you can tell an event rule to set vehicle’s marker on the map to different icons for different speed intervals.

http://gpsgate.com/blogComment/script_notifiers


Regards,
Johan

GpsGate Support

jdewitt
Posts: 108
Joined: Mon Jul 15, 2013 3:26 am
Location: USA

RE: GUIDE: Script Notifiers

Wed Jun 11, 2014 6:34 pm

Another really powerful feature! I tried evaluating it, but when I click the "Edit" button next to the client script editor, I get the following error in the tree control on the right: "Error: Runtime Error". For some reason the namespaces do not load. Any ideas?

jdewitt
Posts: 108
Joined: Mon Jul 15, 2013 3:26 am
Location: USA

RE: GUIDE: Script Notifiers

Wed Jun 11, 2014 6:40 pm

Just checked, I also get the same error when opening the Script Editor from the Device Scripting or Script Expression features.

User avatar
johan
GpsGate
Posts: 14925
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: GUIDE: Script Notifiers

Wed Jun 11, 2014 10:03 pm

Please update Patch.v4 from beta.gpsgate.com and test again.

Regards,
Johan

GpsGate Support

jdewitt
Posts: 108
Joined: Mon Jul 15, 2013 3:26 am
Location: USA

RE: GUIDE: Script Notifiers

Wed Jun 11, 2014 10:34 pm

Works now. Thanks!

jdewitt
Posts: 108
Joined: Mon Jul 15, 2013 3:26 am
Location: USA

RE: GUIDE: Script Notifiers

Wed Jun 11, 2014 10:42 pm

Are you planning to add more map functions to the map namespace over time? It will be great to have a setTrackColor(username)function. I realize that this would require track color to be stored at the track point level vs. track level. However, this will be an excellent way to indicate the duration of an event.

Alon
Posts: 180
Joined: Wed Sep 01, 2004 3:48 pm

RE: GUIDE: Script Notifiers

Wed Jul 09, 2014 8:46 pm

Hi,
How can I use the new <user>.getTags() feature with notifications? I want to show on additional column and send email with the tags of the unit causing the event. I've tried to follow the Script Notifiers blog instruction but couldn't figure it out. I would like also to filter out the "Show on map" tag...
Thanks.

User avatar
johan
GpsGate
Posts: 14925
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: GUIDE: Script Notifiers

Wed Jul 09, 2014 8:47 pm

That method is not part of the Script Notifer API.

Regards,
Johan

GpsGate Support

Alon
Posts: 180
Joined: Wed Sep 01, 2004 3:48 pm

RE: GUIDE: Script Notifiers

Wed Jul 09, 2014 8:59 pm

It will be very useful to have it available for the notification (I already asked your support this feature few weeks ago). It can also be very useful on the columns of Vehicles panel (again with filter 'show on map'.
Is it possible to use <user>.getTags() on report templates?

User avatar
johan
GpsGate
Posts: 14925
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: GUIDE: Script Notifiers

Wed Jul 09, 2014 11:46 pm

You can build the data in the Script Expression and pass it on as a variable to the Script Notifier like this:
topic.asp?TOPIC_ID=17167

Regards,
Johan

GpsGate Support

jdewitt
Posts: 108
Joined: Mon Jul 15, 2013 3:26 am
Location: USA

RE: GUIDE: Script Notifiers

Tue Aug 12, 2014 9:37 pm

Happy to see that setMarkerColor was included in the final release. How do we reset the Marker Color after the event finished?

Kerem
Posts: 23
Joined: Tue Mar 11, 2014 10:47 am
Location: Sweden
Contact: Website

RE: GUIDE: Script Notifiers

Wed Aug 13, 2014 12:51 pm

Hi,

To reset the marker color with the current implementation, you can create two script notifiers under an event rule.

The first script notifier runs when event starts or is pending (by checking "Start" and "Pending" options in "Run this when" dropdown) and it sets the marker color.

The second one is set to be executed when event finishes, and it also sets the marker color, but to a default color (e.g. Map.setMarkerColor('000000'); to set it black).


P.S. We are aware that the initial marker color might be something different than black. Therefore, we will consider implementing a new function which resets the marker color to its initial state.

Regards,
Kerem

GpsGate Support

jdewitt
Posts: 108
Joined: Mon Jul 15, 2013 3:26 am
Location: USA

RE: GUIDE: Script Notifiers

Thu Aug 14, 2014 12:10 am

Thanks for the update Kerem. Yes, it will be needed to reset the color back to the initial color when the event finished, otherwise we are forced to always use the same marker color. Which is the right parameter to use for setting the marker color to red: a) Map.setMarkerColor('#FF0000') or b) Map.setMarkerColor('FF0000')?

Kerem
Posts: 23
Joined: Tue Mar 11, 2014 10:47 am
Location: Sweden
Contact: Website

RE: GUIDE: Script Notifiers

Thu Aug 14, 2014 12:17 pm

You should use Map.setMarkerColor('FF0000'), without number sign. You can always test your script in the script editor before saving it.

Please check "Debugging" under "Rules for Scripting" in this blog post: http://gpsgate.com/blogComment/script_notifiers

Regards,
Kerem

GpsGate Support

jdewitt
Posts: 108
Joined: Mon Jul 15, 2013 3:26 am
Location: USA

RE: GUIDE: Script Notifiers

Thu Aug 14, 2014 6:43 pm

I was testing setting the marker color using a script notifier, but it doesn't work as expected. When setting the marker color at the start of an event it sets it globally. In other words all historic tracks are now the new color. After resetting the color at the end of the event, it sets it globally again. In other words, it is not possible to see the length of the track when an event is active in a different color.

Return to “GpsGate for Developers”