Reglo
Posts: 66
Joined: Wed May 27, 2015 9:09 am
Location: USA

Custom fields in event rules

Tue Aug 04, 2015 6:31 pm

Is it possible to access the value of a custom field in an event rule? The only method I can see is to create a custom variable in Site Admin, then map the custom field to that variable using a Mapper Script, then retrieve the variable in the event rule. However, this is rather convoluted, and probably very inefficient. Is there a better way?

Thanks,
Reglo

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

RE: Custom fields in event rules

Wed Aug 05, 2015 7:20 pm

Please update Patch.v4 from beta.gpsgate.com

exposed .getCustomFieldValue(strLabel) for user objects in Script Expressions

Regards,
Johan

GpsGate Support

Reglo
Posts: 66
Joined: Wed May 27, 2015 9:09 am
Location: USA

RE: Custom fields in event rules

Wed Aug 05, 2015 7:47 pm

The update failed, with a status message: "Could not get registered plugins: strDestinationRootDirectoryPath can not be null." This error doesn't let me get back to the main plugins page.

Thanks,
Reglo

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

RE: Custom fields in event rules

Wed Aug 05, 2015 8:27 pm

Something has happened to your installation that is not related to this particular update.

Can you reload the page?

If you still have problems, you need to contact support @ gpsgate.com and we will trouble shoot this.

Regards,
Johan

GpsGate Support

Reglo
Posts: 66
Joined: Wed May 27, 2015 9:09 am
Location: USA

RE: Custom fields in event rules

Thu Aug 13, 2015 7:00 pm

This update is great, it helped me solve the situation described here: topic.asp?TOPIC_ID=18100

I wanted to provide users with the ability to active/deactivate event rules and select notification options, without giving them full access to the event rule wizard. So I created a custom listbox for each rule, and used script expressions to control the rules accordingly.

Thanks,
Reglo

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

RE: Custom fields in event rules

Fri Aug 14, 2015 3:21 am

Hi Reglo,

Can you share some print screens of what you have done?

Thanks,

Alon

Reglo
Posts: 66
Joined: Wed May 27, 2015 9:09 am
Location: USA

RE: Custom fields in event rules

Fri Aug 14, 2015 5:18 am

Sure Alon.

This is what appears in the "Edit User" dialog:


Image


Each event category is associated with three separate rules: One for email notification, one for SMS notification, and one for display on map (which is active for all options except "disabled").

Here is an example of the Script Expression used for the latter case:

Code: Select all

var tSpeed = session.user.getCustomFieldValue ('Speeding Alert'); //Alert category type
var limit = session.user.getCustomFieldValue ('Speed Limit (mph)');
var vSpeed = fields.get('Speed', null)*2.23694; //Adjust for mph

if(tSpeed != 'Disabled' && vSpeed > limit) return true;
return false;
Best regards,
Reglo

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

RE: Custom fields in event rules

Fri Aug 14, 2015 5:55 am

Excellent, really great flexibility for the end user without needing "technical" support in the events panel.
Many thanks!!

piter197
Posts: 830
Joined: Sun Jan 09, 2011 3:32 am

RE: Custom fields in event rules

Fri Aug 14, 2015 6:51 pm

Hi Reglo, good sharing.

GGS Support, please post tutorial on blog regarding this case.

Best Regards,
piter197

User avatar
juanjogpsgate
GpsGate
Posts: 25
Joined: Wed Oct 08, 2014 12:49 pm
Location: Sweden
Contact: Website

RE: Custom fields in event rules

Tue Aug 25, 2015 5:21 pm

Hi,

we created a new blog entry with a guide about how to set this up.Check it here:

http://gpsgate.com/blogComment/allow_us ... _scripting

Return to “GpsGate for Developers”