Skip to content

Instantly share code, notes, and snippets.

@sn-donbenjamin
Forked from iamwill/debugging_cheatsheet.md
Created October 22, 2019 17:56
Show Gist options
  • Save sn-donbenjamin/444e62a0e3ec6b46b338a82333ef9669 to your computer and use it in GitHub Desktop.
Save sn-donbenjamin/444e62a0e3ec6b46b338a82333ef9669 to your computer and use it in GitHub Desktop.

Revisions

  1. @iamwill iamwill revised this gist Jun 19, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -199,10 +199,10 @@ Method | Description
    `gs.trace(Bool onOff)` | Start/Stop sql tracing. See Example.


    **gs.trace()**
    **gs.trace()**<br/>
    Dump SQL statements to the Eclipse console or Transaction log

    ```javascript
    // SQL statements dumped to Eclipse console or Transaction log
    try {
    gs.trace(true); // Turn on sql tracing for the following statements
    var gr = new GlideRecord('sc_cat_item');
  2. @iamwill iamwill revised this gist Jun 19, 2019. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -198,8 +198,10 @@ Method | Description
    `gs.setProperty(String key, String value)` | Set the value of a Glide property.
    `gs.trace(Bool onOff)` | Start/Stop sql tracing. See Example.

    ```javascript

    **gs.trace()**

    ```javascript
    // SQL statements dumped to Eclipse console or Transaction log
    try {
    gs.trace(true); // Turn on sql tracing for the following statements
  3. @iamwill iamwill revised this gist Jun 19, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -47,7 +47,7 @@ System Diagnostics | Session Debug | These items display output at the bottom of
    System Logs | &nbsp; | Shortcut to logs
    &nbsp; | Transactions | All transactions with summaries of SQL, business rule, and response time
    &nbsp; | All | All syslog entries
    &nbsp; | Script Log Statements | All syslog entries
    &nbsp; | Script Log Statements | Script log messages
    &nbsp; | Node Log File Browser | JVM node output (equivelant to Eclipse console)


  4. @iamwill iamwill revised this gist Jun 19, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,8 @@ Note: Fast! These don't need a database.
    Page | Description
    ---|---
    /stats.do | Stats and Info for the current node
    /xmlstats.do | Same as stats.do but formatted as xml
    /xmlstats.do | Same as stats.do in xml format
    /xmlstats.do?include=cache | Cache stats in xml format
    /thread_pool_stats.do | Thread queue depth and AMB queue
    /sn_agent_workspace_stats.do | Agent workspace build and component versions
    /cancel_my_transaction.do | Name says it all
  5. @iamwill iamwill revised this gist Jun 19, 2019. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -195,6 +195,24 @@ Method | Description
    `gs.getCurrentScopeName()` | Returns the current application scope name.
    `gs.addInfoMessage(String msg)` | Render an info message at the top of a ui page.
    `gs.setProperty(String key, String value)` | Set the value of a Glide property.
    `gs.trace(Bool onOff)` | Start/Stop sql tracing. See Example.

    ```javascript

    // SQL statements dumped to Eclipse console or Transaction log
    try {
    gs.trace(true); // Turn on sql tracing for the following statements
    var gr = new GlideRecord('sc_cat_item');
    gr.get('bd6fa75a4f334200086eeed18110c79e');
    if(gr.isValid()) {
    gs.info(gr.getDisplayValue('name'));
    gs.info(gr.getDisplayValue('short_description'));
    }
    } finally {
    gs.trace(false); // Turn off sql tracing
    }

    ```

    ### GlideStopWatch :arrow_down:

  6. @iamwill iamwill revised this gist Jun 19, 2019. 1 changed file with 0 additions and 3 deletions.
    3 changes: 0 additions & 3 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -239,9 +239,6 @@ While this property is true, the entire jelly template include structure is dump
    -->sys_report_template0.xml
    ```

    **?sysparm_direct=true** <br />
    Render any ui page without the html_page_template.

    ## Cache

    ### GlideCacheManager :arrow_down:
  7. @iamwill iamwill revised this gist Jun 19, 2019. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -7,11 +7,11 @@ Set `com.glide.util.Log.developer_filter = true` to cut down on non-interactive

    ### Utility urls

    Note: These do not hit the database
    Note: Fast! These don't need a database.

    Page | Description
    ---|---
    /stats.do | Fast! Stats and Info for the current node
    /stats.do | Stats and Info for the current node
    /xmlstats.do | Same as stats.do but formatted as xml
    /thread_pool_stats.do | Thread queue depth and AMB queue
    /sn_agent_workspace_stats.do | Agent workspace build and component versions
    @@ -176,7 +176,7 @@ When the dom changes, it will pause the script execution so you can examine the
    ## Server Scripting

    **/sys.scripts.do**<br/>
    Write and execute freeform script on the server. You will also find scripts from all of your active plugin's `sys.scripts/` folder.
    Write and execute freeform script on the server. You will also find scripts from all of your active plugin `*/sys.scripts/` folders.

    ### Useful Tables

    @@ -272,7 +272,7 @@ sys_cache_flush | Cache flushes are written here to sync cache flushing across n

    ## Java

    ### Server Request 101
    ### Overview of a Server Request

    1. GlideServlet.doRequest() <- It all starts here
    1. GlideServletQuickTransaction.process()
  8. @iamwill iamwill revised this gist Jun 18, 2019. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -202,9 +202,10 @@ A convenient utility for calculating script run time.

    Method | Description
    ---|---
    `start()` | (Optional) Start the timer. The constructor automatically starts the timer.
    `stop()` | Stop the timer.
    `getTime()` | Returns the time in milliseconds.
    `start()` | (Optional) Start the timer. The constructor automatically starts the timer
    `stop()` | Stop the timer
    `getTime()` | Returns the time in milliseconds
    `toString()` | Returns formatted time elapsed

    ```javascript
    var t = new GlideStopWatch();
  9. @iamwill iamwill revised this gist Jun 18, 2019. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -33,6 +33,8 @@ sys_glide_object | Field/Element types, extensions, and class mapping

    Administrators can use these navigator modules: System Diagnostics & System Logs. Below are some highlights:

    :arrow_down:

    Application | Module | Description
    ---|---|---
    System Diagnostics | Session Debug | These items display output at the bottom of the page
    @@ -87,7 +89,7 @@ sys_translated_txt | TXT | Values for field type: Translated Text
    sys_ui_message | MSG | Values for `getMessage(key)`


    ### Plugin shortcuts
    ### Plugin shortcuts :arrow_down:

    **Is plugin active?**
    ```javascript
    @@ -126,14 +128,14 @@ sys_script_client | Table based client scripts (onChange, onLoad, onSubmit)
    **gs.setProperty('glide.ui.js_includes', false);** <br />
    While this property is false, JS include bundling and whitespace removal is disabled and every javascript file is downloaded separately and untouched.

    **ctrl + shift + j**<br/>
    **ctrl + shift + j** :arrow_down:<br/>
    Launch the JavascriptExecutor to evaluate some js on the current ui page.

    ```javascript
    g_form.setValue('short_description', 'Hello World');
    ```

    **Remember!**<br/>
    **Remember!** :arrow_down:<br/>
    In many parts of our platform we include prototypeJS.
    - `$` = getElementById
    - `$j` is jQuery.
    @@ -160,7 +162,7 @@ Shortcut | Description
    `console.dir(obj)` | Prints a JSON representation of an object
    `console.log(obj)` | Prints a message or object to the console

    **Angular scope**<br/>
    **Angular scope** :arrow_down:<br/>
    Some of our applications are using angular. Use this shortcut to view the scope of the current angular directive.
    1) Using the element inspector, select an element.
    2) Type this in the console: `angular.element($0).scope()`
    @@ -194,7 +196,7 @@ Method | Description
    `gs.addInfoMessage(String msg)` | Render an info message at the top of a ui page.
    `gs.setProperty(String key, String value)` | Set the value of a Glide property.

    ### GlideStopWatch
    ### GlideStopWatch :arrow_down:

    A convenient utility for calculating script run time.

    @@ -222,6 +224,7 @@ Use this tag to dump all jelly variables in scope to the transaction log.
    **gs.setProperty('glide.ui.template.trace', true);** <br />
    While this property is true, the entire jelly template include structure is dumped to the transaction log.

    :arrow_down:
    ```
    ->html_page.xml
    -->html_page_css.xml
    @@ -240,7 +243,7 @@ Render any ui page without the html_page_template.

    ## Cache

    ### GlideCacheManager
    ### GlideCacheManager :arrow_down:
    The primary caching api in the platform, a Java static Hashtable. See CacheManager.java.

    **GlideCacheManager.get(String catalog, String key)**</br>
    @@ -257,7 +260,7 @@ Put an item in the cache.
    Page | Description
    ---|---
    /cache_inspect.do | Browse the Private and Shared caches
    /cache.do | Flush all the caches
    /cache.do | Flush all the caches (Do not do on customer instance without approval!)

    ### Useful Tables

    @@ -306,7 +309,7 @@ Note: **Direct UI pages don't use default page template.**
    - UI pages where direct=true


    ### Remote Debugging (Connect to a remote node)<br/>
    ### Remote Debugging (Connect to a remote node) :arrow_down: <br/>

    *Taken from KB0536116 on BuildTools1*
    1. Permission: ask customer for permission before conducting remote debugging. Nobody else can use the instance during that time because any action on the instance will potentially trigger your breakpoint.
    @@ -322,7 +325,7 @@ Note: **Direct UI pages don't use default page template.**

    ## Performance

    All instances include a performance dashboard for monitoring:
    All instances include a performance dashboard for monitoring: :arrow_down:
    - Transaction counts & response time
    - Memory usage
    - Errors & logs
    @@ -337,6 +340,3 @@ syslog_transaction | User transaction log
    syslog_cancellation | Logs cancelled transactions
    syslog | All system logs (Info, Warning, Error)




  10. @iamwill iamwill revised this gist Jun 18, 2019. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -96,7 +96,7 @@ gs.info(pm.isRegistered("com.glide.i18n")); //true

    **Activate/Upgrade plugin**
    ```javascript
    pm.registerPlugin("com.glide.i18n");
    pm.registerPlugin("com.glide.i18n"); // Activate a plugin and all nested dependencies
    ```

    **Load a plugin's demo data**
    @@ -336,3 +336,7 @@ sys_query_pattern | Slow queries for later optimization
    syslog_transaction | User transaction log
    syslog_cancellation | Logs cancelled transactions
    syslog | All system logs (Info, Warning, Error)




  11. @iamwill iamwill revised this gist Jun 18, 2019. 1 changed file with 5 additions and 7 deletions.
    12 changes: 5 additions & 7 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,11 @@ Set `com.glide.util.Log.developer_filter = true` to cut down on non-interactive

    ### Utility urls

    Note: These do not hit the database

    Page | Description
    ---|---
    /stats.do | Stats and Info for the current node
    /stats.do | Fast! Stats and Info for the current node
    /xmlstats.do | Same as stats.do but formatted as xml
    /thread_pool_stats.do | Thread queue depth and AMB queue
    /sn_agent_workspace_stats.do | Agent workspace build and component versions
    @@ -29,7 +31,7 @@ sys_glide_object | Field/Element types, extensions, and class mapping

    ### Debug modules

    Administrators can use these navigator modules: System Diagnostics & System Logs. Below are some higlights:
    Administrators can use these navigator modules: System Diagnostics & System Logs. Below are some highlights:

    Application | Module | Description
    ---|---|---
    @@ -82,7 +84,7 @@ sys_choice | CHC | Choice list options
    sys_documentation | GMLD | Field labels
    sys_translated | TRF | Values for field types: Translated Name & Translated Field
    sys_translated_txt | TXT | Values for field type: Translated Text
    sys_ui_message | MSG |
    sys_ui_message | MSG | Values for `getMessage(key)`


    ### Plugin shortcuts
    @@ -334,7 +336,3 @@ sys_query_pattern | Slow queries for later optimization
    syslog_transaction | User transaction log
    syslog_cancellation | Logs cancelled transactions
    syslog | All system logs (Info, Warning, Error)




  12. @iamwill iamwill revised this gist Jun 18, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -74,7 +74,8 @@ Set this property = true to enable prefixes on all translated text.
    **Plugin: I18N: Internationalization**<br/>
    Activate this plugin to test localization prefixes for just your session! Use **Enable I18N Debugging** in the navigator.

    **Translations are stored in the following tables:**</br>
    **Translations are stored in the following tables:**

    Table | Debug Prefix | Description
    ---|---|---
    sys_choice | CHC | Choice list options
  13. @iamwill iamwill revised this gist Jun 18, 2019. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -56,6 +56,7 @@ Elevate your role from the User Menu.
    - Impersonate the different user from the User Menu.

    **ACL Types**<br/>

    Type | Description
    --- | ---
    processor | Restrict execution of a processor
    @@ -332,3 +333,7 @@ sys_query_pattern | Slow queries for later optimization
    syslog_transaction | User transaction log
    syslog_cancellation | Logs cancelled transactions
    syslog | All system logs (Info, Warning, Error)




  14. @iamwill iamwill revised this gist Jun 18, 2019. 1 changed file with 61 additions and 6 deletions.
    67 changes: 61 additions & 6 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,9 @@

    ## Platform Troubleshooting

    **Console output too chatty?**<br/>
    Set `com.glide.util.Log.developer_filter = true` to cut down on non-interactive console log entries such as scheduled workers. (Don't forget to remove it when you're done!)

    ### Utility urls

    Page | Description
    @@ -22,6 +25,7 @@ sys_db_object | All of the physical database tables
    sys_dictionary | Tables and columns and their attributes
    sys_glide_object | Field/Element types, extensions, and class mapping

    **Note:** All element defaults come from sys_glide_object.

    ### Debug modules

    @@ -42,7 +46,63 @@ System Logs | &nbsp; | Shortcut to logs
    &nbsp; | Node Log File Browser | JVM node output (equivelant to Eclipse console)


    **Find Zboot date**<br/>
    ### Security

    **Can't edit an ACL?**<br/>
    Elevate your role from the User Menu.

    **Troubleshooting issues for a specific user?**<br/>
    - First, enable any debug modules such as Debug SQL and Debug Security.
    - Impersonate the different user from the User Menu.

    **ACL Types**<br/>
    Type | Description
    --- | ---
    processor | Restrict execution of a processor
    record | Restrict Execute/CRUD operations on Tables and Columns
    REST_Endpoint | Restrict execution of rest endpoints
    ui_page | Restrict access to UI pages by name
    ux_page | Restrict access to paths provided by UX builder


    ### Localization

    **glide.ui.i18n_test** (Note: this is system wide)<br/>
    Set this property = true to enable prefixes on all translated text.

    **Plugin: I18N: Internationalization**<br/>
    Activate this plugin to test localization prefixes for just your session! Use **Enable I18N Debugging** in the navigator.

    **Translations are stored in the following tables:**</br>
    Table | Debug Prefix | Description
    ---|---|---
    sys_choice | CHC | Choice list options
    sys_documentation | GMLD | Field labels
    sys_translated | TRF | Values for field types: Translated Name & Translated Field
    sys_translated_txt | TXT | Values for field type: Translated Text
    sys_ui_message | MSG |


    ### Plugin shortcuts

    **Is plugin active?**
    ```javascript
    gs.info(pm.isRegistered("com.glide.i18n")); //true
    ```

    **Activate/Upgrade plugin**
    ```javascript
    pm.registerPlugin("com.glide.i18n");
    ```

    **Load a plugin's demo data**
    ```javascript
    pm.loadDemoData("com.glide.service-portal.esm")
    ```

    ### Zboot

    **Find Zboot date & time**<br/>
    ```javascript
    var gr = new GlideRecord("sys_db_object");
    gr.get("name", "sys_dictionary");
    @@ -125,7 +185,6 @@ Method | Description
    ---|---
    `gs.info(String msg, [String params])` | Log an info message, and print the message to the console. Include optional params in log message.
    `gs.log(String msg, [String source])` | Log a message to the system log with an optional source argument.
    `gs.print(String msg)` | Print a message to the instance console.
    `gs.breaker(obj)` | Put a breakpoint in `GlideSystem.js_breaker()` to stop here whenever you use gs.breaker() in a server script.
    `gs.getCurrentScopeName()` | Returns the current application scope name.
    `gs.addInfoMessage(String msg)` | Render an info message at the top of a ui page.
    @@ -273,7 +332,3 @@ sys_query_pattern | Slow queries for later optimization
    syslog_transaction | User transaction log
    syslog_cancellation | Logs cancelled transactions
    syslog | All system logs (Info, Warning, Error)




  15. @iamwill iamwill revised this gist Jun 18, 2019. 1 changed file with 76 additions and 3 deletions.
    79 changes: 76 additions & 3 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,55 @@
    # Debugging tips and tricks

    ## Platform Troubleshooting

    ### Utility urls

    Page | Description
    ---|---
    /stats.do | Stats and Info for the current node
    /xmlstats.do | Same as stats.do but formatted as xml
    /thread_pool_stats.do | Thread queue depth and AMB queue
    /sn_agent_workspace_stats.do | Agent workspace build and component versions
    /cancel_my_transaction.do | Name says it all
    /side_door.do | Bypass SSO redirect and go to login.do
    /logout.do | Immediately log out

    ### Useful Tables

    Table | Description
    ---|---
    sys_db_object | All of the physical database tables
    sys_dictionary | Tables and columns and their attributes
    sys_glide_object | Field/Element types, extensions, and class mapping


    ### Debug modules

    Administrators can use these navigator modules: System Diagnostics & System Logs. Below are some higlights:

    Application | Module | Description
    ---|---|---
    System Diagnostics | Session Debug | These items display output at the bottom of the page
    &nbsp; | Enable All | Enable all debug options
    &nbsp; | Debug Business Rule | Show all business rule evaluations
    &nbsp; | Debug Log | Show script log messages
    &nbsp; | Debug SQL | Show SQL queries and execution time
    &nbsp; | Debug Security | Show ACL evaluations
    System Logs | &nbsp; | Shortcut to logs
    &nbsp; | Transactions | All transactions with summaries of SQL, business rule, and response time
    &nbsp; | All | All syslog entries
    &nbsp; | Script Log Statements | All syslog entries
    &nbsp; | Node Log File Browser | JVM node output (equivelant to Eclipse console)


    **Find Zboot date**<br/>
    ```javascript
    var gr = new GlideRecord("sys_db_object");
    gr.get("name", "sys_dictionary");
    gs.print(gr.getDisplayValue("sys_created_on")); // 2019-06-18 03:10:14
    ```


    ## Client Scripting

    ### Useful Tables
    @@ -195,12 +245,35 @@ Note: **Direct UI pages don't use default page template.**

    ### Remote Debugging (Connect to a remote node)<br/>

    1. Permission: ask customer for permission before conducting remote debugging. Ask for at least 8 hours dedicated to just yourself. Customer can't use the instance during that time, because any action on the instance will potentially trigger your breakpoint. So this should be conducted on a test or development instance.
    *Taken from KB0536116 on BuildTools1*
    1. Permission: ask customer for permission before conducting remote debugging. Nobody else can use the instance during that time because any action on the instance will potentially trigger your breakpoint.
    1. Ask SRE to change JVM parameter and restart customer instance (Customer support action).
    1. Identify some good candidates for break points. You should have some good understanding of the problem you are trying to solve before conducting remote debugging.
    1. You should have a good understanding of the problem you are trying to solve before conducting remote debugging.
    1. When you request remote debugging, you are asked to specify an app node on the instance. That's the one you'll attach to.
    1. Hop2node on customer's instance
    1. Go to /xmlstats.do
    1. find the jvm.java_opts parameters
    1. Locate the debug port, eg: -Xdebug -Xrunjdwp:transport=dt_socket,address=**10001**,server=y,suspend=n
    1. Configure your IDE to launch a Remote Java Application using that port, eg 10001
    1. Configure your IDE to launch a Remote Java Application using that port, eg 10001


    ## Performance

    All instances include a performance dashboard for monitoring:
    - Transaction counts & response time
    - Memory usage
    - Errors & logs
    - Slow queries & more

    ### Useful Tables

    Table | Description
    ---|---
    sys_query_pattern | Slow queries for later optimization
    syslog_transaction | User transaction log
    syslog_cancellation | Logs cancelled transactions
    syslog | All system logs (Info, Warning, Error)




  16. @iamwill iamwill revised this gist Jun 18, 2019. 1 changed file with 186 additions and 4 deletions.
    190 changes: 186 additions & 4 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,112 @@
    # Debugging tips and tricks

    ## Client Scripting

    ### Useful Tables

    Table | Description
    ---|---
    sys_ui_script | UI Scripts. Note: scripts where global=true are included on every ui page.
    sys_script_client | Table based client scripts (onChange, onLoad, onSubmit)

    **gs.setProperty('glide.ui.js_includes', false);** <br />
    While this property is false, JS include bundling and whitespace removal is disabled and every javascript file is downloaded separately and untouched.

    **ctrl + shift + j**<br/>
    Launch the JavascriptExecutor to evaluate some js on the current ui page.

    ```javascript
    g_form.setValue('short_description', 'Hello World');
    ```

    **Remember!**<br/>
    In many parts of our platform we include prototypeJS.
    - `$` = getElementById
    - `$j` is jQuery.


    ### Chrome dev tools (command + option + J)

    Important! **Target the gsft_main frame**<br/>
    When using the javascript console, make sure you are picking the frame named: gsft_main

    **breakpoint;**<br/>
    Pause javascript execution and launch the script debugger in your browser. Only works when your browser dev tools are open.

    ```javascript
    function onSubmit() {
    breakpoint; // Your script execution will pause and automatically launch the debugger.
    }
    ```

    Shortcut | Description
    ---|---
    `$0` | Currently selected dom element
    `$1` | Previously selected dom element
    `console.dir(obj)` | Prints a JSON representation of an object
    `console.log(obj)` | Prints a message or object to the console

    **Angular scope**<br/>
    Some of our applications are using angular. Use this shortcut to view the scope of the current angular directive.
    1) Using the element inspector, select an element.
    2) Type this in the console: `angular.element($0).scope()`

    **Break On**</br>
    What code is changing the dom? Right click on the parent element in the element inspector and select Break On -> Subtree Modifications.

    When the dom changes, it will pause the script execution so you can examine the stack trace.


    ## Server Scripting

    **/sys.scripts.do**<br/>
    Write and execute freeform script on the server. You will also find scripts from all of your active plugin's `sys.scripts/` folder.

    ### Useful Tables

    Table | Description
    ---|---
    sys_script | Business rules
    sys_script_include | Server Script includes

    ### GlideSystem APIs

    Method | Description
    ---|---
    `gs.info(String msg, [String params])` | Log an info message, and print the message to the console. Include optional params in log message.
    `gs.log(String msg, [String source])` | Log a message to the system log with an optional source argument.
    `gs.print(String msg)` | Print a message to the instance console.
    `gs.breaker(obj)` | Put a breakpoint in `GlideSystem.js_breaker()` to stop here whenever you use gs.breaker() in a server script.
    `gs.getCurrentScopeName()` | Returns the current application scope name.
    `gs.addInfoMessage(String msg)` | Render an info message at the top of a ui page.
    `gs.setProperty(String key, String value)` | Set the value of a Glide property.

    ### GlideStopWatch

    A convenient utility for calculating script run time.

    Method | Description
    ---|---
    `start()` | (Optional) Start the timer. The constructor automatically starts the timer.
    `stop()` | Stop the timer.
    `getTime()` | Returns the time in milliseconds.

    ```javascript
    var t = new GlideStopWatch();
    var gr = new GlideRecord("incident");
    gr.addActiveQuery();
    gr.query();
    gr.getRowCount();
    gs.print(t.getTime()); // 2
    ```


    ## Jelly

    **<g:breakpoint />** <br/>
    Use this tag to dump all jelly variables in scope to the transaction log.



    **GlideProperties.set('glide.ui.template.trace', true);** <br />
    **gs.setProperty('glide.ui.template.trace', true);** <br />
    While this property is true, the entire jelly template include structure is dumped to the transaction log.

    ```
    @@ -21,4 +120,87 @@ While this property is true, the entire jelly template include structure is dump
    -->output_messages2.xml
    <--output_messages2.xml 0:00:00.006
    -->sys_report_template0.xml
    ```
    ```

    **?sysparm_direct=true** <br />
    Render any ui page without the html_page_template.

    ## Cache

    ### GlideCacheManager
    The primary caching api in the platform, a Java static Hashtable. See CacheManager.java.

    **GlideCacheManager.get(String catalog, String key)**</br>
    Get an item from the cache.

    **GlideCacheManager.flush()**<br/>
    Flush the cache. Same as going to /cache.do.

    **GlideCacheManager.put(String catalog, Object key, Object value)**<br/>
    Put an item in the cache.

    ### Utility urls

    Page | Description
    ---|---
    /cache_inspect.do | Browse the Private and Shared caches
    /cache.do | Flush all the caches

    ### Useful Tables

    Table | Description
    ---|---
    sys_db_cache | Database-backed cache records are stored here. (Such as syscache_realform with phase 1 jelly output)
    sys_cache_flush | Cache flushes are written here to sync cache flushing across nodes.

    ## Java

    ### Server Request 101

    1. GlideServlet.doRequest() <- It all starts here
    1. GlideServletQuickTransaction.process()
    1. doStaticContent() &nbsp;&nbsp;&nbsp;&nbsp; - Serve static content: .cssdbx,.gif,.jpg,.htm
    1. doCancelRequest() &nbsp;&nbsp;&nbsp;&nbsp; - Cancel running transaction
    1. DiagnosticTransaction &nbsp;&nbsp;&nbsp;&nbsp; - /stats.do
    1. GlideServletTransaction.process()
    1. ProcessorRegistry.process()
    1. See **Which Processor?**
    1. GlideServletUITransaction
    1. RedirectTransaction &nbsp;&nbsp;&nbsp;&nbsp; - Handles form save
    2. NavigationTransaction &nbsp;&nbsp;&nbsp;&nbsp; - Displays UI pages
    1. See **GlideForm**

    ### Which processor?

    This is the order that processors are determined:
    1. Finds processor by Parameter (abc_list.do?**XML**, abc_list.do?**EXCEL**, abc_list.do?**CHART**)
    1. Find processor by exact path (**PATH**.do)
    1. Find processor by extension (/incident.**EXTENSION**)
    1. Otherwise, default processor is **GlideServletUITransaction**

    ### GlideForm

    The GlideForm class constructs nearly all Jelly based UI pages, including forms & lists!

    Default page template: `html_page_template.xml`

    Note: **Direct UI pages don't use default page template.**

    **Direct UI pages:**

    - **$** prefix ($vtb.do)
    - ?sysparm_direct=true
    - UI pages where direct=true


    ### Remote Debugging (Connect to a remote node)<br/>

    1. Permission: ask customer for permission before conducting remote debugging. Ask for at least 8 hours dedicated to just yourself. Customer can't use the instance during that time, because any action on the instance will potentially trigger your breakpoint. So this should be conducted on a test or development instance.
    1. Ask SRE to change JVM parameter and restart customer instance (Customer support action).
    1. Identify some good candidates for break points. You should have some good understanding of the problem you are trying to solve before conducting remote debugging.
    1. When you request remote debugging, you are asked to specify an app node on the instance. That's the one you'll attach to.
    1. Hop2node on customer's instance
    1. Go to /xmlstats.do
    1. find the jvm.java_opts parameters
    1. Locate the debug port, eg: -Xdebug -Xrunjdwp:transport=dt_socket,address=**10001**,server=y,suspend=n
    1. Configure your IDE to launch a Remote Java Application using that port, eg 10001
  17. @iamwill iamwill created this gist Jun 5, 2019.
    24 changes: 24 additions & 0 deletions debugging_cheatsheet.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # Debugging tips and tricks

    ## Jelly

    **<g:breakpoint />** <br/>
    Use this tag to dump all jelly variables in scope to the transaction log.



    **GlideProperties.set('glide.ui.template.trace', true);** <br />
    While this property is true, the entire jelly template include structure is dumped to the transaction log.

    ```
    ->html_page.xml
    -->html_page_css.xml
    <--html_page_css.xml 0:00:00.003
    -->html_page_javascript.xml
    --->html_page_javascript_db.xml
    <---html_page_javascript_db.xml 0:00:00.005
    <--html_page_javascript.xml 0:00:00.025
    -->output_messages2.xml
    <--output_messages2.xml 0:00:00.006
    -->sys_report_template0.xml
    ```