GreenArrow Email Software Documentation

User Defined JavaScript

GreenArrow Studio supports the ability for System Administrators to include a special JavaScript file on all pages in the web interface. They may also be overridden on an individual user basis.

This can be used to add new features or automation to the application by modifying the web-pages inside of the browser DOM.

Support Limitations

Please use great caution in creating user defined JavaScript because it is possible to break the GreenArrow Studio application.

GreenArrow can only address bugs that can be replicated when the user defined JavaScript is off.

GreenArrow can not support customer written JavaScript or assist in writing JavaScript.

Updates to GreenArrow may change the DOM or the HTML of the application at any time, changing the behavior of or breaking customer written JavaScript.

GreenArrow is not responsible for fixing customer written JavaScript that was broken by a GreenArrow update.

This feature is not available for GreenArrow Cloud customers.

Enabling User Defined Javascript

To enable this feature, run the following command as root:

cd /var/hvmail/studio && bundle exec rake features:user_javascript:enable

Disabling User Defined Javascript

Warning

Disabling this feature will remove the JavaScript-related settings from all users in the system


To disable it run the following command as root:

cd /var/hvmail/studio && bundle exec rake features:user_javascript:disable

Setting a System-Wide JavaScript File

Navigate to the System configuration screen. In the top section, there is a JavaScript subsection. Edit the Global JavaScript URL, setting a URL to the JavaScript file to load.

Configure System-Wide JavaScript File

Disabling custom JavaScript for a System Administrator

To turn off custom JavaScript loading for a System Administrator, navigate to that user’s edit page. Set Custom JavaScript to Do not load custom JavaScript.

This setting will persist when using the Sign In As feature.

Disabling JavaScript for a System Administrator

Setting a different custom JavaScript for a System Administrator

You may set a different URL to load for System Administrators to use on a per-user basis. This is useful for developing new JavaScript features.

To set a different custom JavaScript file, navigate to that user’s edit page. Set Custom JavaScript to Use a different JavaScript URL than the system setting. Set User JavaScript URL to the new URL.

This setting will persist when using the Sign In As feature.

Setting a different custom JavaScript for a System Administrator

User and Organization Data

When this feature flag is enabled, all pages will contain window.ApplicationData.User and window.ApplicationData.Organization variables.

These variables will contain data visible to the currently signed in user.

window.ApplicationData = {};

window.ApplicationData.User = {
  "id": 1,
  "full_name": "GreenArrow System Admin",
  "email": "[email protected]",
  "active": true,
  "role": "system_admin",
  "show_quick_tips": true
};

window.ApplicationData.Organization = {
  "id": 1,
  "name": "System Organization",
  "anniversary_day": 1,
  "time_zone_name": "(GMT-06:00) Central Time (US & Canada)",
  "time_zone_utc_offset": -21600,
  "active": true,
  "html_header": "",
  "html_footer": "",
  "text_header": "",
  "text_footer": ""
};

This is the same data provided via the User and Organization APIs – with the omission of the permissions keys.


Copyright © 2012–2019 GreenArrow Email