It is ServiceNow’s new release season! With the Orlando release in Early Access, we will show some enhancements targeted around being more effective and efficient as a developer. These tools are specifically for developers and scripting on the Now Platform.
Script Include Dependency
A new contextual menu has appeared for your script includes. You might already be familiar with the open definition when using the contextual menu on a script include. Added in Orlando is a reference search to find the application files with scripts that invoke the targeted script include. The list will be limited to the most common application file types listed in the hover text. Business Rule, UI Page, UI Policy, List Controls, Widgets, Scripted REST API, Workflow Action, Flow Action. If you wish to search more than those files, the show all files option should be utilized. The dependency checker can be handy when deciding to make a change. The risk can be better assessed and mitigated by knowing the impacted scripts and applications they support.
Show All Files
The API for the query is available and can be tested with the API Explorer. Namespace: now API Name: Syntax Editor , Get References (POST). The parameters follow this example. searchWord: “ArrayUtil”, searchWordType: “script_include”, searchTables: [“sys_script”, “sys_script_include”, “sys_ui_page”], ignoredTables: [ “sys_ui_policy”, “sys_security_acl”, ]
A new addition you might not be familiar with is Log points. When in a script editor in the platform, the left hand of the syntax editor hides some gems. The first thing to do is set the property to enable log points. glide.debug.log_point Once that is done, they will be available in addition to breakpoints when right-clicking in the syntax editor.
The logpoint functionality allows for adding of line-specific logs, without having to add logs directly into your script. The logpoints are stored outside of the script and attached to your specific user. That flexibility allows for them even to be used in production when needed because the script is not modified. The logpoint field accepts the same syntax and variables as you would have used to insert logs directly: gs.warn(‘I have an array of friends ‘+ current.number); is a valid example. Each developer can have their logpoints denoted by the green arrow and should remove them when they are no longer needed. To view these logpoints, you can use the script debugger/session log window, with ‘log’ debugging turned on.
The studio integration with GitHub source control now has the added feature of allowing you to select which files and from which developer you wish to apply a commit from ServiceNow to a remote source control system.
From above, you can see along the left-hand side are the users with updates, so I can filter if I wish to only commit one user’s application files. Next to each application file is a checkbox to select it to commit, along with a compare link. When the selection is made, the next screen offers a summary and a commit comment message box. You should provide a commit message that will be relevant for reviewers and future developers. You could be one of those future developers, so do yourself a favor and provide useful information.
Edit files outside of ServiceNow
Source control integration has taken a significant step in adding the ability to edit the contents of the repository outside of ServiceNow directly. Previously, a checksum prevented any editing at all. The checksum is still available via a system property if you wish to retain those protections: glide.source_control.checksum_required. When the checksum is present and valid, the validation and sanitization checks that have been added to enable outside editing will be skipped. The sanitation process will remove files and folders that are not relevant to the ServiceNow data structure. A Readme.txt file is an excellent example of a file that can be added to a repository to render useful information to someone viewing the repository but would be ignored when synchronized with ServiceNow.
The opening of this door allows for the use of utilities and practices. Branching and merging can now be performed outside of the platform, enabling more robust development processes. There are many whole blogs on the topic of source control out in the wild that are now more relevant to explore. Throw your favorite ones in the comments below to share with other developers. The new CICD API for committing from a branch can be useful to explore. The Live Code Happy Hour YouTube series has recently had 3 episodes on CICD.
Note: branches created outside the platform might not be visible inside studio until a sync event happens.
Mid Server support for source control systems behind your corporate firewall is now available. When setting up an application to link to GIT, the option to select a mid server is selectable. Avoid using mid servers that are primarily tasked for discovery.
These new features for developers get me excited! Share comments below the feature that has most helped you that was added in New York or Orlando or let us know which feature for studio and script editor is not yet added. ServiceNow is open to your ideas and feedback. You can use the idea portal in the community to add and vote on enhancements along with sharing them in the comments below.