JavaScript Scripting Framework

Starting with Civic Platform 8.0.1, master scripts (version 3.0) allow customizations using a JavaScript-based framework instead of the legacy Standard Choice Script Controls. With the JavaScript framework, script developers can leverage the following features:

  • Use of standard JavaScript syntax
    • Faster development times
    • Decreased learning curve for new Accela developers
    • Cleaner, more readable code
    • Support for IDE tools and syntax highlighting
  • Improved error-handling and debugging
    • Errors reference appropriate lines in code
    • Improved script tester code
    • Use of try/catch for error handling
    • Debugging is 10x faster
  • EMSE Tool integration
    • EMSE Tool integrates with version control systems (SVN and Git)
    • Enables standards based configuration management of script code
    • Custom functions and event scripts can be contained in individual files for better organization
    • Easy migration of scripts between environmentsBasic set of scripting variables, standard functions, flow of execution
The following diagram illustrates a typical script development process using the JavaScript framework with the master scripts:


Comparing the JavaScript Framework with Legacy Script Controls

The JavaScript framework eliminates the legacy coding mechanism required by the legacy Standard Choice script controls:

No more Standard Choice script controls: Earlier Master Scripts relied on several shortcuts, primarily in an attempt to make the code easier to read in the compressed space in Standard Choices. The JavaScript scripting framework does away with these shortcuts and uses pure JavaScript instead.

No more Standard Choice line numbers: Scripts using the JavaScript framework are stored in the scripts area instead of Standard Choices. There is no longer a need to indicate the order of execution with a line number. Instead the JavaScript code is evaluated top-to-bottom.

No more "Carets" as if/then/else: Probably the most prominent difference is the elimination of the caret ^ to separate if/then/else clauses. JavaScript has a different purpose for the caret, so this notation is no longer allowed.
  • Using legacy Script Controls:
    wfStatus== "Issued" ^ editAppStatus("Issued",""); ^ editAppStatus("Not Issued","");
  • Using JavaScript:
    if (wfStatus== "Issued") {  
      editAppStatus("Issued", "");
    } else {
      editAppStatus("Not Issued", "");
    }

No more branch() function: The legacy branch() function was used to shift code execution to a different Standard Choice, much like a subroutine in other programming languages. Instead of calling the branch function, call a custom JavaScript function.

  • Using legacy Script Controls:
    branch("EMSE:AddBuildingFees");
  • Using JavaScript:
    addBuildingFees();

No more curly braces around custom ("ASI") fields: Earlier master scripts used curly braces { } surrounding an ASI / TSI / Parcel Attribute label to substitute the value of that field. Instead, place the custom field name in a JavaScript string array called AInfo.

  • Using legacy Script Controls:
    {Square Footage} > 10
  • Using JavaScript:
    AInfo["Square Footage"] > 10

If you are new with JavaScript, see JavaScript Primer or any JavaScript tutorial and reference on the internet.