DevTools 1.13.0

Welcome to the DevTools - created and maintained by Sascha Wildgrube.

Features

DevTools contains a number of script includes with useful javascript functions and classes like a GetType() function that realy works. A few UI improvements like the Re-Test button in the test result form and shortcuts to various - sometimes hidden - views and system properties in your instance.

Disclaimer

DevTools is NOT an officially supported ServiceNow product.

DevTools does NOT come with any kind of warranty. If you use it, you own it!

System Requirements

  • New York, Orlando, Paris or Quebec

Installation

To use the full potential of DevTools perform the following steps:

  1. To install DevTools create an account on GitHub (if not done already).
  2. Paris or later: Add credentials to access GitHub (Use "Basic Auth").
  3. Fork the repository https://github.com/saschawildgrube/servicenow-devtools.
  4. Go to Studio and import the DevTools application from source control.
  5. Switch to global scope
  6. Create a new update set in the global scope to capture all changes related to the DevTools installation.
  7. Note that the following steps might be considered as a breach of security guidelines and should be validated with those who are responsible for security within the instance!
  8. Set the system property glide.record.legacy_cross_scope_access_policy_in_script to true.
  9. In order to run the installation script which configures new system property categories enable create, read, write and delete operations for all applications on the following tables:
    1. sys_properties
    2. sys_properties_category_m2m
  10. In order to run all DevTools ATF tests enable create, read, write and delete operations for all applications on the following tables:
    1. sys_user
    2. sys_user_group
    3. sys_user_role
    4. incident
    5. incident_task
    6. change_request
    7. change_task
    8. problem
    9. problem_task
    10. sc_request
  11. In order use the RunScriptInGlobalScope() function enable create, read, write and delete operations for all applications on the following table:
    1. sys_script_include
  12. Go to the "Install Script" module and execute the script.
  13. Go to the "Install Log" module and check for error messages. In case of errors, wait a few minutes and retry. The access changes to the tables might take a few minutes to be effective.
  14. Set the update set in the global scope to to complete.
  15. Go to "Instance Debug Options" and activate the ATF test execution (if not set already).
  16. Run the DevTools Test Suite
  17. In case of errors:
    1. Tests "DevTools - GetGroupsFromUser" and "DevTools - TestDataAPI": Retry after a few minutes. Some cross-scrope privileges will be set up during the first test run and might take a few minutes to be effective.
    2. Test "DevTools - TestDataAPI": This script creates various records (e.g. incidents and problems). If there are customizations in place that make additional fields mandatory, you may have to set up business rules to set these values - but only if the short description (or the corresponding field) starts with "_ATF_".

Reference

Configuration options

Script includes

  • AppSanity

    Performs a number of changes to a scoped app's assets to maintain applicaton sanity. E.g. the function removes the copied_from attribute in atf tests. This function requires the RunScriptInGlobalScope() function.

  • ArrayUnique

    Returns an array with unique values only.

  • ArrayValueExists

    Checks if a value exists in an array and returns true in that case, otherwise false.

  • BusinessRuleGetOperation

    Returns the operation (of a business rule) based on the provided record.

  • Clone

    Creates a copy of the given value.

  • Debug

    Produce a debug log output but only if x_snc_devtools.debug.log is set to true.

  • DocumentationAPI

    The DocumentationAPI helps to render fragements of an HTML page that documents the components of a scoped application.

  • GetAppName

    Returns the name of a scoped application (and removes any "work in progress" postfixes).

  • GetArrayValue

    Returns an array no matter what input type is given and performs necessary conversion if another type is provided.

  • GetBoolValue

    Returns either true or false no matter what kind of value is given.

  • GetGroupsFromUser

    Returns all groups of a given user. An additional filter can be applied to the groups to be returned.

  • GetIntegerValue

    Returns an integer value.

  • GetKeys

    Returns all key names of an object in an array. Returns an empty array if no object is provided or no members exist.

  • GetRecordFromTestStep

    Returns the sys_id of the record that has been created or found in the given test step.

  • GetRolesFromUser

    Returns an array with the sys_ids of the active roles of a user.

  • GetStringValue

    Returns a string value in all cases. Arrays and objects are converted into comma separated strings.

  • GetTimeNow

    Returns the number of milisenconds passed since the start of the unix epoch.

  • GetTransactionRuntime

    Returns the number of milisenconds passed since the start of this transaction.

  • GetType

    Returns the type of a value.

  • GetValue

    Returns the value of an object that is (or is not) part of an recursive object without generating errors if the object does not exist.

  • HtmlEncode

    Converts a string to html.

  • HttpRequest

    Performs a single http request.

  • IsEqual

    Checks if two values are equal. The function also supports arrays and can ignore the order of array elements while comparing.

  • IsObject

    Returns true if the given value is an object. False if not.

  • IsTableCrossScopeAccessible

    Checks if a table is fully scross-scope accessible. The function returns true if the access is set to public and apps from other scopes are allowed to perform read, create, update and delete operations.

  • IsUserHasRoleExactly

    Returns true of the current user has the provided role explicitly. Returns true if that is the case, returns false if not. If an admin does not explicitly have that role, it will also return false.

  • IsUserSecurityAdmin

    Returns true if the current user is elevated to security_admin, false if not.

  • IsValidRecord

    Checks if the given record is a valid glide record object. Returns true if it is, false if not.

  • IsValidSysId

    Checks if the given string is a syntactically correct sys_id. Returns true if it is, false if not.

  • IsValidVersion

    Returns true if the given string is a valid version number, false if not.

  • IsVersionCompatible

    Checks if the first version is compatible to the second version - whereas the first version is the version of an installed application and the second version is a requirement.

  • LoadMessages

    Loads all local test messages for an "application".

  • Log

    Produces a log output

  • Merge

    Merges two objects.

  • ParseDateTime

    Parses a string and returns a time value.

  • ParseJson

    Parses a string and returns an object or false in case of failure (instead of pointlessly throwing an exception).

  • RecordBulkProcessor

    A function to process large amounts of records using a callback function. The function makes use of a specified date/time field to determine which record to process next. Multiple instances of a background script can run using this function to work on large amounts of records in a table without interfering with each other. For large tables it is imperative to add an index on the date time field!

  • RecordSetValue

    Sets a single field value on a given record.

  • RenderDateTime

    Renders a date/time value as an UTC ISO string.

  • RenderValue

    Render any value as a string. In case of objects, the keys are displayed in alphabetical order. In case of arrays, the elements are displayed in the given order. In case of a GlideRecord, the table name, sys_id and number (if available) are displayed on top and a selected choice of fields leads the list of values despite the alphabetical order.

  • RunScriptInGlobalScope

    Run any script in the global scope even if the context is a scoped application. However the function requires full cross scope access configured for the sys_script_include table. Note that the script will be placed into a function body so you cannot assume that declared local variables will be valid after its execution.

  • StopWatch

    The StopWatch class measures time in the same way as a real stop watch does.

  • StringRemoveCharacters

    The function returns the input string with all characters removed that are contained in the blacklist string.

  • TestDataAPI

    A class to create test data records.

  • TransactionCacheAPI

    A class to manage the transaction cache.

Test step configurations

DevTools contains the following customized test step configurations:

License

Copyright 2020-2021 by Sascha Wildgrube

Licensed under the Apache License, Version 2.0 (the "License")

You may not use DevTools except in compliance with the License.

You may obtain a copy of the License at: https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Release Notes

1.13.0 - 2021-04-15

  1. Added the StopWatch class which serves exactly as what its name suggests.
  2. Added function GetTimeNow() which is a shorthand for "new Date().getTime()".
  3. Added function GetTransactionRuntime() to return the amount of miliseconds passed since the start of the current transaction.
  4. GetGroupsFromUser() can now return the list of a user's groups with an encoded filter applied to the groups.
  5. Added function BusinessRuleGetOperation() to return the operation (of a business rule) based on the provided record.
  6. Debug() can now display the current transaction runtime in milliseconds. The new property x_snc_devtools.debug.log.transaction_runtime controls if the transaction runtime should be included or not.
  7. RenderValue() has been improved: In case of a GlideRecord, the table name, sys_id and number (if available) are displayed on top and a selected choice of fields leads the list of values despite the alphabetical order.
  8. The test step configuration "DevTools - Check scoped app sanity" now checks scheduled jobs for only technical users or the system admin serve as the run_as user.
  9. Added module "Query Log" to track invalid queries.
  10. The module "Outbox" is renamed to "Outbox or Sent" and also displays sent mails.
  11. Improved column order in module "Storage Column Aliases".

1.12.2 - 2021-03-22

  1. Fixed a defect in IsVersionCompatible().

1.12.1 - 2021-03-22

  1. Fixed a defect in the test step configuration "DevTools - Check scoped app sanity".

1.12.0 - 2021-03-22

  1. RecordBulkProcessor() will no longer process the same record twice in one go.
  2. Test step configuration "DevTools - Check scoped app sanity" now checks for useless field level ACLs.
  3. Test step configuration "DevTools - Check scoped app sanity" now checks for misconfigured test steps.
  4. Test step configuration "DevTools - Check table cross scope access" checks if "Caller access" is set to "Caller Restriction".
  5. Added a comprehensive syntax editor macro for "RecordBulkProcessor" with boilerplate code.

1.11.0 - 2021-03-19

  1. Madrid is no longer supported.
  2. Added function RecordBulkProcessor() to process large amounts of records using a callback function.
  3. Added function Clone() to clone objects. This is to heal the JavaScript inherent design flaw around object references instead of copies.
  4. Added function Merge() to merge two objects.
  5. Added function RecordSetValue() to set a single field value on a given record.
  6. Added function IsObject() to distinguish objects from other types.
  7. Added function IsValidTable() since the TableUtils script include is not accessible from a scoped app.
  8. Added function RenderDateTime() since Javascript has no built-in function to render an ISO date/time string.
  9. Added function Sleep() to do nothing for a set amount of seconds.
  10. RenderValue() now has a second parameter "bHideEmpty". If set to true, empty values in objects are ignored - leading to better readable output.
  11. RenderValue() sorts keys of objects alphabetically. However the keys "name", "short_description", "number" and "sys_id" will always lead the pack.
  12. RenderValue() now displays empty objects as "{}".
  13. IsEqual() can now compare objects.
  14. TestDataAPI: Added function GetAllData() and corresponding functions for each supported record type GetAllIncidents(), GetAllProblems(), etc.
  15. TestDataAPI: Added function CreateTestItem() and GetAllTestItems() to manage entries in the table x_snc_devtools_test which is used for testing.
  16. ParseDateTime() is now more resilient against incorrect input.
  17. The test step configuration "DevTools - Check scoped app sanity" now checks for empty descriptions in publicly accessible script includes.
  18. Improved installation intructions.

1.10.0 - 2021-02-26

  1. Added function GetAppName() to return the name of a scoped application but without any name postfixes to indicate work in progress. This function is needed to create clean test step configuration descriptions.
  2. Added function AppSanity() which performs a number of changes to a scoped app's assets to maintain applicaton sanity. E.g. the function removes the copied_from attribute in atf tests.
  3. RenderValue() was improved: In case of objects, the keys are displayed in alphabetical order. In case of arrays, the elements are displayed in the given order as before.
  4. Added function DocumentationAPI::RenderListItem() and refactored all Render*() functions.
  5. The test step configuration "DevTools - Check scoped app sanity" now checks for jelly breakpoints in UI pages.
  6. Added configuration options section to the documentation.
  7. Removed unnecessary debug logging in TestDataAPI.

1.9.0 - 2021-02-15

  1. Quebec is now supported.
  2. Added function GetRolesFromUser() to get the sys_ids of all active roles of a user.
  3. Added function TestDataAPI::CreateRole() to create a role for testing purposes.
  4. TestDataAPI::CreateUser() now also accepts the name of a role without the prefix.
  5. Added function DocumentationAPI::RenderInstallationInstructionsImportFromSourceControl() to render installation instructions for importing an application from source control.
  6. Added function DocumentationAPI::RenderDisclaimer().
  7. Improved the rendering of script include documentation in DocumentationAPI::RenderScriptIncludes().
  8. Added missing description to the DocumentationAPI script include.
  9. Test step configuration "DevTools - Check scoped app sanity" now checks if the app's short_description is empty.
  10. Test step configuration "DevTools - Check scoped app sanity" now checks if a module's link_type is set to "HTML" (which doesn't work properly).

1.8.0 - 2021-01-21

  1. Added the DocumentationAPI class to render HTML fragments for a documentation UI page.

1.7.0 - 2021-01-20

  1. Added function IsValidVersion() to check for a valid (ServiceNow app) version string.
  2. Added function IsVersionCompatible() to check a version against a requirement.
  3. Added test step configuration "DevTools - Check scoped app dependency". This test step configuration checks if another required scoped application is installed in a (backward) compatible version.
  4. Added module "Background Script" to open the background script page in a new window.
  5. Added new navigation section "Transaction" and moved all transaction related modules into it.
  6. Added new navigation section "Cache" for easy access to the cache inspection tool and to flush the cache.
  7. Added new navigation section "Events" to easily access the event log, event registry, notifications and outbox.
  8. Added more test cases for GetIntegerValue().

1.6.0 - 2021-01-14

  1. Added function IsTableCrossScopeAccessible() to check if applications from other scopes can perform read, create, update and delete operations on the given table.
  2. Added function RunScriptInGlobalScope() to run a script in the global scope from within a scoped application. Note that the function required full cross scope access to the sys_script_include table.
  3. IsEqual() now uses type strict comparison and will no longer return true in case of IsEqual(1,"1").
  4. The "Rerun Test" button has been renamed to "Run Test" and is now available on all forms that directly refer to an ATF test (including test steps).
  5. The ATF tests "TestDataAPI" and "GetGroupsFromUser" now make use of the "DevTools - IsTableCrossScopeAccessible" test step configuration to check if the croos scope access to the tables is configured.
  6. The ATF test "Installation" now checks if the system property glide.record.legacy_cross_scope_access_policy_in_script is set to true to avoid cross scope access policy errors. Refer to KB0711970.

1.5.0 - 2020-11-23

  1. Added test step configuration "DevTools - Check scoped app sanity". This test step configuration takes a scoped application and checks if all its sys_properties are NOT set to private and all ATF tests have an empty copied_from field. More checks will be added later.
  2. Added test step configuration "DevTools - Check table cross scope access"
  3. Added test step configurations to the documentation.
  4. Added test "DevTools - Installation" to check if all relevant tables are configured according to the installation guide.
  5. Added test "DevTools - App Sanity" to check if the app sanity is ok.
  6. Added table sys_user to the list of tables which need full cross scope access.

1.4.0 - 2020-11-16

  1. Added function IsUserSecurityAdmin().

1.3.0 - 2020-11-04

  1. Added class TransactionCacheAPI.
  2. Added function HtmlEncode().
  3. Added function GetKeys().
  4. Added function StringRemoveCharacters().
  5. Part of the documentation is generated automatically based on record descriptions.

1.2.4 - 2020-09-10

  1. ParseDateTime() has been repaired, aligned to UTC and the corresponding test has been implemented.
  2. LoadMessages() now takes the language as the second parameter. Defaults to 'en'.
  3. GetBoolValue() was not accessible out of scope. This has been fixed.
  4. IsValidRecord() now also checks for type ScopedGlideRecord and ScopedGlideRecordSecure. The ATF test has been updated accordingly.
  5. TestDataAPI functions now display the sys_ids of created records in the log.
  6. Added the "Cancel Transactions" module.
  7. Added test and macro for IsUserHasRoleExactly().
  8. Added the system property x_snc_devtools.ui.list_button to control if the "List" button should be visible or not.
  9. Extended documentation with a reference to all script includes.

1.2.3 - 2020-08-21

  1. Added the "Transaction Log" module.
  2. "Evaluator Log", "Debug Log" and "App Log" modules only show the last 30 minutes.
  3. Added the "Storage Column Aliases" module.
  4. RenderValue() can now work properly with nested objects.

1.2.2 - 2020-08-02

  1. RenderValue() no longer causes the following error: com.glide.script.fencing.MethodNotAllowedException: Function getValue is not allowed in scope x_snc_devtools.

1.2.1 - 2020-07-30

  1. GetArrayValue() now returns an empty array for an empty string.

1.2.0 - 2020-07-07

  1. Added TestDataAPI.CreateRequest() and extended the ATF test "DevTools - TestDataAPI"
  2. Refactoring of several functions in TestDataAPI. Caller and Opener users can now be set explicitly.
  3. Added function IsValidRecord()

1.1.0 - 2020-07-03

  1. Added TestDataAPI.CreateProblem() and TestDataAPI.CreateProblemTask()
  2. The install script is now a scheduled script that can be run on demand instead of a fix script that runs automatically.

1.0.0 - 2020-06-23

First baselined version