Adding Custom Functions

Civic Platform master scripts provide a placeholder to include the INCLUDES_CUSTOM master script file.

eval(getScriptText("INCLUDES_CUSTOM"));

Custom functions are stored in the INCLUDES_CUSTOM.js file. The practice used with the legacy Standard Choice script controls was to manually add the custom functions into the INCLUDES_CUSTOM script, as described in Manually Updating INCLUDES_CUSTOM. A better way to create custom functions is by Using the JavaScript Framework to Create Custom Functions.

Using the JavaScript Framework to Create Custom Functions

Instead of manually adding all custom functions into the INCLUDES_CUSTOM file, Accela recommends the use of separate custom function JavaScript files within the JavaScript Scripting Framework to implement customizations to the master scripts. The use of separate JavaScript files facilitates easier creating, storing, and managing of the custom functions. The following summarizes the process:
  1. Setup a script repository, which includes a folder named INCLUDES_CUSTOM.
  2. For each custom function, create a JavaScript file in the INCLUDES_CUSTOM folder. Use the name of the function as the JavaScript filename.
    Note: A custom function using the JavaScript framework no longer requires the branch() function used with the legacy Standard Choice script controls. See Comparing the JavaScript Framework with Legacy Script Controls for details.
  3. Build and deploy the INCLUDES_CUSTOM script using the EMSE tool.

Manually Updating INCLUDES_CUSTOM

This section describes the legacy process of adding new custom functions by manually updating the INCLUDES_CUSTOM file. To create new functions, save your customizations in a file named INCLUDES_CUSTOM.js.

Note:

To prevent the Civic Platform installer from overwriting existing customizations during a product upgrade, Civic Platform does not provide the INCLUDES_CUSTOM master script file as part of the Civic Platform installer.

If the INCLUDES_ACCELA_FUNCTIONS and INCLUDES_CUSTOM contain a function with the same name, the function in the INCLUDES_CUSTOM file overwrites the function in the INCLUDES_ACCELA_FUNCTIONS file.

Do not modify functions in the INCLUDES_ACCELA_FUNCTIONS file. If you want to modify a function from the INCLUDES_ACCELA_FUNCTIONS file, create a same named function with the different functionality in the INCLUDES_CUSTOM file.

As a best practice, use a commenting structure in your INCLUDES_CUSTOM file to keep it organized and easy to interpret. The following provides and example.

/**************** Modified Accela Standard Functions (Start) **************/ 
//All modified Accela standard functions will live here 
/**************** Modified Accela Standard Functions (End) ****************/ 
/**************** Custom Building Functions (Start) **************/ 
//All custom building functions will live here 
/**************** Custom Building Functions (End) ****************/ 
/**************** Custom Licensing Functions (Start) **************/ 
//All custom licensing functions will live here 
/**************** Custom licensing Functions (End) ****************/ 
/**************** Custom Planning Functions (Start) **************/ 
//All custom planning functions will live here 
/**************** Custom planning Functions (End) ****************/ 
/* Start a new section for each logical group */