Notifications

106 views

Description

After copying the kb_knowledge Delete button and clicking on the copy, it does nothing and generates the error "Uncaught TypeError: Cannot read property 'GlideModal' of null".

Steps to Reproduce

  1. Copy the Delete UI Action for the kb_knowledge table
  2. Edit an article
  3. Open a developer console in your browser
  4. Click on the copy of the Delete UI Action
  5. Observe the error message "Uncaught TypeError: Cannot read property 'GlideModal' of null"

Cause

This is expected behavior because the UI action is run in strict mode, which causes the runtime issue. Basically, when running in strict mode you are not allowed to access any DOM elements. In particular, this includes the use of window.

Many of the base system scripts are allowed to run in non-strict mode, but by copying the existing UI action you are forced into strict mode.

Resolution

There are several ways to address this issue:

  1. The correct way to re-write this script to run in strict mode would be:
    var dialogClass = (typeof GlideModal !== 'undefined') ? GlideModal : GlideDialogWindow;
  2. New client-scripts are run in strict mode, this removes direct access to the DOM, jQuery, prototype, and the window object.
    • To turn this off this on a per-script basis
      1. Configure this form to add the "Isolate script" field
      2. Disable the field.
    • To disable this feature for all new globally-scoped client-side scripts set the system property "glide.script.block.client.globals" to false. If this property is not present in your 'System Properties > All Properties' [sys_properties] table, you can add it:
      1. Go to the sys_properties.list
      2. Click New
      3. Populate the form
        • Name: glide.script.block.client.globals
        • Type: true|false
        • Value: false

Article Information

Last Updated:2019-10-09 05:00:44
Published:2019-10-09