1. Overview

July 14, 2021


What is an Erply back office Javascript plugin?

A back office Javascript plugin is a piece of Javascript code that gets included (and executed) on every page load. In back office (Classic as well as Berlin), each user interaction (opening a record, saving it, running a search, loading next page of search results) generally results in a new page load.

 

It is up to the plugin to watch what page was loaded, and act appropriately. A plugin that wants to create a new menu bar button, should naturally execute its payload on every request. A plugin that wants to rearrange product card, should first check if the current page is a product form.

 

A lot of environment information is available via global, predefined Javascript variables. If you open "View Source" on a back office page, there are a number of Javascript variables defined there:

 
var url_install = 'https://t1.erply.com/1234/';
var child_window = null;
var conf_name = 'mt';
var conf_subname = '';
var page_lang = 'eng';
var section = 'prodmoves';
var subsection = '';
var conf_dateformat = 'm/d/Y';
var conf_date_monthdayformat = 'm/d';
var datepicker_format = conf_dateformat.replace("Y", "yyyy").replace("m", "mm").replace("d", "dd");
var datepicker_firstDay = 0;

var thousandsSeparator = ',';
var decimalSymbol = '.';
var priceDecimals = 2;

var conf_attendants = '0';
var new_menu = 1;

var customerCode = '1234';
var apiSessionKey = 'abcd1efgh';
…
 

Variable "section", for example, defines the type of the current page — is it the product form, the list of invoices, or something else? 

 

Variable "recordID" provides the ID of the currently opened record, if user is on a form. (If user is entering a new record and it has not been saved yet, "recordID" equals 0.)

 

There is a variable "apiSessionKey" with which the plugin can issue calls to API. 

 

Etc.

 

These variables are documented below, in section "Context Variables".