Add custom functions to master scripts
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. You can create custom functions using JavaScript. (See Create custom function with the JavaScript Framework for more information.) If you are still using the standard choice script controls, you will manually add the custom functions into the INCLUDES_CUSTOM script. (See Manually update INCLUDES_CUSTOM for more information.)
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. See JavaScript scripting framework overview for more information. The use of separate JavaScript files facilitates easier creating, storing, and managing of the custom functions. The following summarizes the process:
-
Set up a script repository, which includes a folder named INCLUDES_CUSTOM. See The EMSE tool and the script repository for more information.
-
For each custom function, create a JavaScript file in the INCLUDES_CUSTOM folder. Use the name of the function as the JavaScript file name.
Note: A custom function using the JavaScript framework no longer requires the branch() function used with the legacy standard choice script controls. See JavaScript scripting framework overview. -
Build and deploy the INCLUDES_CUSTOM script using the EMSE tool. See Pull the INCLUDES_CUSTOM script for more information.
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.
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 */