Skip navigation

THE PROBLEM WITH OOB CAPABILITIES

Those of you who've had rigorous testing protocols on ServiceNow know that there's a critical weakness with notification handling on non-production systems.  You have only three options:

  1. Disable all notifications - "Great, now I can't test notifications at all!" 
  2. Enable all notifications - "Great, now my customers get notifications they neither want nor expect"  x2
  3. Send all notifications to specified email addresses -  "Great, now my testers have to separate signal from noise"

 

There must be a better way.

 

SOLUTION:  FILTER INTENDED RECIPIENTS

We need a solution that provides the following

  • Req1 - authorize whole groups to receive notifications on non-prod
  • Req2 - authorize single users to receive notifications on non-prod
  • Req3 - exists on all instances, but only works on non-prod instances

 

We'll provide this solution with one dictionary entry and one before-insert business rule.

 

First, we build a true/false field named u_subprodemail on the Group table only.  You might look at Req2 and say "don't we need this on User table too"?  Nope!  We're solving two use cases here.  First is flagging whole groups that want to receive notifications.  For individuals, we'll simply create a new group (with u_subprodemail = true) that we can put those 'one of' users in.

 

Now we create a Before Insert business rule on the Sys_Email table.  We're going to intercept outbound email and bend it to our will!

NAME:  Control Sub-Prod Email

CONDITION

gs.getProperty('glide.servlet.uri') != "https://<yourinstancename>.service-now.com" && current.type != "received"

 

SCRIPT:

function onBefore(current, previous) {
  var validSends = [];
  var ga = new GlideAggregate('sys_user_grmember');
  ga.addQuery('group.u_subprod_email',true);
  ga.groupBy('user');
  ga.query();
  while (ga.next()){
    if (current.recipients.indexOf(ga.user.email.toString()) >= 0){
      validSends.push(ga.user.email.toString());
    }
  }
  current.recipients = validSends.toString();
  current.body = "SENT FROM NON-PRODUCTION SYSTEM \n\n" + current.body;
  gs.log(gs.getProperty('glide.servlet.uri') + " " + validSends, 'Sub-Prod Notifications');
}

 

SCRIPT EXPLAINED

  • We declare validSends variable as a blank array.
  • We query the sys_user_grmember table finding all group members for groups that have the u_subprod_email set to true.
  • We’re using GlideAggregate and GroupBy so that multiple memberships with the same User are represented only once.
  • For each result we compare the group member’s email against the list of recipients targeted for the sys_email insert.
  • If there’s a match, we push the value to the validSends array.
  • After we’ve tested all validated addresses, we overwrite current.recipients with validSends.
  • We also add text to the top of the email body to reinforce it was sent from a non-prod system.
  • REMEMBER:  Because we're checking *group memberships* to groups that have been flagged as enabled, you may have users part of multiple groups, only one which is email enabled.  A user only needs one "enabled" membership to receive all email targeted at them.

 

CONGRATULATIONS!

  • You can include notifications as a component of your UAT. 
  • You can precision control the groups and users to receive those notifications.
  • You can push this customization to prod so you don't have to rebuild it after every clone-back.

If you are trying to add a field to a large table, such as a Task, you may encounter a couple of issues on your instance. If you are trying to add a field to the Task table and it is taking much longer than the default UI transaction quote rule of 5 minutes, you may experience a blank screen and the change will not show up on the update set. Although the field has been created in the table, it may impact your instance in two ways:

  1. You’ll have no record of it in the current update set.
  2. The field is created on the database, but the Dictionary record is missing.

This is likely occurring because your transaction is being timed out and canceled by a UI transactions quota rule. Transaction quotas allow administrators to define a quota policy for different types of transactions. Once defined, the quota rule can cancel any transaction that doesn't follow the policy and notifies you that it has been canceled. Typically, you’ll get cancellation message like this:

 

Transaction_cancelled.jpg

 

The log also shows that this was canceled by the UI transactions quota rule (see also Viewing Cancelled Transactions):

 

Transaction_cancelled_log.jpg

 

Administrators set transaction quotas to prevent poorly performing queries from using up system resources and preventing other transactions from running. To avoid this issue, you can reduce the size of the affected table or adjust the quota rules to allow the system modules to wait for the transaction to complete.

Clean up the affected table

To reduce the size of the table, you can delete unused records and/or columns to decrease the time required for the database transaction. By default, background scripts are exempt from UI transactions quota. Importing an update set to an instance where a table size is not reduced will not have the same issue as transactions from the update set import that will not time out.

 

Adjust the quota rules

This will allow the system modules to wait for the transaction to complete.

  1. Navigate to System Definition > Quota Rules.
  2. Select the UI Transactions rule.
  3. Add these conditions:
    • [URL] [does not contain] [sys_dictionary] – This allows deletion from the dictionary.
    • [URL] [does not contain] [sys_db_object] – This allows creation from the table.
    • [URL] [does not contain] [slushbucket.do] – This allows creation from the form.
    • [URL] [does not contain] [sys_remote_update_set.do] – This allows creation from an remote update set.
    • [URL] [does not contain] [sys_update_set.do] –  This allows creation from an update set.

The example below shows the [URL] [does not contain] [sys_dictionary] condition added to the transaction quota rule:

 

Quota_Transaction_Rule.jpg
This issue has been seen in quite a few patches and hot fixes in Calgary, Dublin and Eureka. You can subscribe to KB0547328: Adding a field to a large table such as Task is canceled by the "UI Transactions" Quota Rule, failing to add the change to an update set to be notified when the workaround, fixed in or description has been updated.

Slava

Carbon Paper 2.0

Posted by Slava Jun 23, 2015

It is no secret for any ServiceNow administrator that there are lots of situations where you need to copy information from one record to another or even create a new record as a copy of another record. The easiest way to do it programmatically is to execute a script similar to this:

 

var usr_id = 'ddc2b4edfc81b800f0d8e21d514cc2a4';
var gr = new GlideRecord('sys_user');
gr.get(usr_id);
gr.insert();

 

The script above finds a user record by sys_id and uses insert() method to create an exact copy. Of course, two identical user records is probably not something you would really like to have in your application. In a real-life scenario, you will most likely want to change at least the name of the user. Here is a way to do it:

 

var usr_id = 'ddc2b4edfc81b800f0d8e21d514cc2a4';
var gr = new GlideRecord('sys_user');
gr.get(usr_id);
gr.first_name = 'John';
gr.last_name = 'Smith';
gr.insert();

 

There are, however, at least three things that will not be copied by a script like this.

 

1. Journal fields

 

The contents of all journal fields in the system are actually stored in Journal Entry [sys_journal_field] table. You will need to query that table to copy Work Notes or Additional Comments.

 

2. Attachments

 

When you attach a file to any record in ServiceNow, it is saved in Attachment [sys_attachment] table. To copy attachments, use the following piece of code:

 

if (typeof GlideSysAttachment != 'undefined') {
   // for Calgary and newer versions
   GlideSysAttachment.copy('source_table', 'sys_id', 'target_table', 'sys_id');
} else {
   // for Berlin and older versions
   Packages.com.glide.ui.SysAttachment.copy('source_table', 'sys_id', 'target_table', 'sys_id');
}


3. Image and video fields

 

There are two types of image fields in ServiceNow: image (e.g. Icon field in Module records) and user_image (e.g. Photo field in User records). The former contains a link to an image. The latter contains… nothing. You can easily verify that by exporting any user record that has a photo to XML. In fact, images uploaded into user_image fields are physically stored in Attachment [sys_attachment] table, the only difference from usual attachments being ZZ_YY prefix in the Table Name attribute. The same is valid for video type fields. As a result, anything you upload to Images [db_image] or Video [db_video] tables ends up in Attachments [sys_attachment] table.

The visual task board (VTB) is a interactive tool that allows you and your team to collaborate on multiple task records in real time. Any user can create, view, and edit visual task boards, and share these boards for other users to view and edit.

 

Your task board consists of a quick panel, lanes, cards and activity stream. You can add task cards, edit card details, add labels to cards, and access the task record, depending on the type of board you've created. In addition, you can move the cards between lanes and keep track of recent activity using the activity stream in the top right.

 

For tips on using VTBs, check out 6 tips for using Visual Task Boards by chuck.warner and this knowledge15 session Visual Task Boards: Interact with Work More Efficiently.

 

Visual task board.png

 

If you need to edit your short description in Eureka, you may encounter an error message when you double-click the card that opens in a pop-up: An error occurred saving your change. Please verify you have permission to make this change.

Don’t fret. Chances are, you do have permission, just not access to edit from here. There are many options for quickly editing the short description for your task.

 

How to edit the short description on your visual task board:

 

Choose from the following options:

  • Edit the text directly from the card in the lane on the Visual Task Board (click on the short description to open the field to edit):

    Description edit from card.png
  • Navigate to the pop-up form of the record to edit:

    popup record with INT number in background.jpg


You can also:

  • Edit the short description from the list view:
    Description edit from list view.png
  • Edit the short description from the form view:

    Description edit from popup form view.png

 

(Note: You may receive this message if you attempt a move that you don't have permission for, like a lane change, because of ACLs. In that case, it is an expected result, and not an error. So double-check your ACLs before submitting an incident or reporting an issue.)

 

If you are on Eureka Patch 6, Eureka Patch 6 Hot Fix2, Eureka Patch 6 Hot Fix 4 or Eureka Patch 7, you could run into this problem. This issue is fixed in Eureka Patch 9. You can get more information about this issue in ServiceNow KB: Visual Task Board permission error when editing Short Description from the pop-up card (KB0547013). 

Slava

Looking through your eyes

Posted by Slava Jun 16, 2015

Quite often there is a need to set up reports that return different results depending on who runs them. In versions before Dublin, it could be done fairly easily using scripted filters. With introduction of dynamic filter options in Dublin, this feature has become even more intuitive as you no longer need to memorize things like gs.getUserID() or getMyGroups(). What is not as straightforward, however, is testing of such reports.

 

In many cases, reports are created by non-admin users directly in a production instance where for security reasons you cannot allow them to impersonate other users (those who will be using the reports). Requiring all reports to be created in a test instance first is also not an option. Non-admin users will not be able to transfer reports between instances and will either have to redo them in production or involve system administrators, which is too much of an overhead. Besides, a test instance may not have the most recent data even if you clone it from production regularly.

 

If this problem sounds familiar to you, here is a workaround you might find helpful. Instead of using gs.getUserID() or getMyGroups() in reports, you can create your own functions that will return the ID or the list of groups of another user depending on the value of a user preference:

 

1. Create a very simple UI page with a reference field pointing to Users [sys_user] table. This is where your report creators will choose a user through whose eyes they want to view reports. Use processing script to save their selection as a user preference.

 

2. Make this UI page accessible via a module in the navigation pane, a UI action in the user’s profile, or elsewhere. Since the page is so simplistic, you may want to display it in a GlideDialogWindow to make it look elegant.

 

view_reports_as.png

 

3. In a global business rule, define functions that will read the user preference and return results based on its value. If no preference is set for the current user, these functions should default to the out-of-box ones, such as gs.getUserID() or getMyGroups().

 

function getRepUserID() {
    var view_as_user = gs.getUser().getPreference('view_reports_as');

    if (view_as_user == null || view_as_user == '')
        view_as_user = gs.getUserID();

    return view_as_user;
}

function getRepGroups() {
    var view_as_sys_id = getRepUserID();
    var view_as_groups = gs.getUser().getUserByID(view_as_sys_id).getMyGroups();

    return view_as_groups;
}

 

 

4. Finally, create dynamic filter options that will leverage the new functions and, optionally, hide the out-of-box ones.

 

Important! This solution does not change the security context in any way. Results returned by the reports will be constrained by security rules applicable to the current user, not the one indicated in the user preference.

rodeo.jpegCreateNow makes building apps fun and easy - over forty of our customers and partners in beautiful Calgary built their first app yesterday at the App Dev Workshop.  We have been holding these free, four hour App Dev Workshop across the globe and if you are interested to have one in your city please ping me or contact your local sales team.  You can also go through the material by following the instructions here.  You will need your own instance, which you can get it for free by signing up for our developer program.  While you are on the developer site, check out all the other training we have available.

 

Looking for ideas on what app to build - check out the app showcase and let us know if you want your app featured there.

If you are using Internet Explorer, you may find that your UI14 interface is not working in Eureka. The reason for this could be that the Internet Explorer developer mode is set incorrectly or the Compatibility View is on.

 

What does this mean? If a local machine has a policy that defines ServiceNow as an intranet site, IE displays these sites in Compatibility Mode by default, which disables UI14. Another reason could be that the document mode and user-agent string in the IE F12 Developer Tools, which are designed for building and debugging your web page, are set incorrectly. The Developer Tools are set to 7 by default on IE 9, 10, and 11 when the ServiceNow website is treated like an intranet site. If set less than 9, this causes the UI to fail when accessing the Eureka instance.

 

To correct this, we recommended that you upgrade to an newer version of Internet Explorer to avoid performance issues. If that's not an option, you can also disable the Compatibility View on your instance or IE, or reset the Developer Tools.

 

How to disable Compatibility View on your instance:


Setting the  glide.ui.allow_ie_compatibility_mode property to false overrides the browser's compatibility settings and forces the application out of Compatibility View. This allows UI14 to run on Internet Explorer on versions prior to IE9 without breaking the interface. To disable:

  1. In the navigation filter, enter sys_properties.list.
  2. Go to glide.ui.allow_ie_compatibility_mode.
  3. Set the value to False.
  4. Click Update.

 

compatiblity view false.png

 

How to disable Compatibility View in IE:

  1. From the Tools menu, open the Compatibility View settings.
  2. Uncheck the Display intranet sites.

 

How to set F12 Developer Tools in IE:

  1. Log in to your instance.
  2. Open F12 Developer Tools in Internet Explorer (you can click F12 or go to the tools icon and select F12 tools).
  3. Go to Emulation.
  4. Change the document mode to 9 and user-agent string to Internet Explorer 9.
  5. Log out and back in.

 

We strongly advise that you upgrade to a new version of IE to prevent performance issues. Otherwise, use the workarounds above until you are able to upgrade.

 

Having more issues using Internet Explorer and your ServiceNow instance? See:

This week we're zeroing in on a important User Interface issue that could impact performance if not addressed carefully. Let's take a look at KB0549424: Creating a UNIQUE index via the UI with online alter enabled corrupts the table if the data is not unique and determine what we need to know.

 

Last summer, we received reports from customers that data was lost when they attempted to add a unique index via the UI. At the time, we were unable to reproduce the issue and had not seen additional cases until more users started upgrading in late fall. A closer look determined that online alter was enabled and the online alter process needed to validate that the data was unique prior to modifying the index table. Failure to do so resulted in records not being inserted into the new table structure and data being lost. This was due to the INSERT IGNORE bypassing the unique key violations.

 

After adding indexes with a unique constraint, you will see these symptoms if your instance is affected:

  • Table corruption
  • Data loss
  • Failure to insert records into the table

 

This issue was found to have originated in Calgary, when online alter was introduced. We investigated this issue and implemented a fix in Eureka Patch 8.

 

For customers who are unable to upgrade to Eureka Patch 8 and are using releases from Calgary to Eureka Patch 7, the following workaround is recommended:

 

To prevent the loss of data when a unique index is needed and an upgrade is not possible, please use the script below to verify the contents of the column manually before adding the index. The user can determine if there are any duplicate values before creating a unique index by using a script in "Script - Background" such as:

 

// This script will: select a, count(*) from table and group by a having count(*) > 1
var tableName = 'table_we_will_add_the_index_to';
var columnName = 'column_that_will_get_the_new_index';

var ga = new GlideAggregate(tableName);
ga.addAggregate('count', columnName);
ga.groupBy(columnName);
ga.addHaving('count','>','1');
ga.query();
if (ga.next()) {
  gs.print('The column ' + columnName + ' on table ' + tableName + ' has duplicates.  Creating a unique index will result in data loss.');
} else {
  gs.print('The column ' + columnName + ' on table ' + tableName + ' does not have duplicate values.');
}





 

If non-unique values are found, remove or rename the duplicate values so they are unique.  Once completed, creating a unique index will no longer result in data loss.

Developers Header.png

CreateNow Developers,

 

As promised, we wanted to get out a monthly update as to what has been released and what we are working on with the Developers Site and Program.  Expect this blog to go out on a monthly basis, or if we have something incredible to talk about, bi-monthly.

 

Last update was directly to the early access folks just before Knowledge.  We have come out of our deep freeze to provide some content updates and great feature enhancements.

 

Content Updates:

Based on the incredible feedback you have provided us we have made considerable updates to the training courses.  We have received so much feedback on the Building an Example ServiceNow Application that we have removed it from the navigation to restructure it. We appreciate those that provided feedback taking the time to help us get things right.  You can still access it here.


New Features:

  • My Instance page
    • Last status time – Upper right of the frame tells you the last time the status was updated.
    • Activity description – Hovering over the last activity date provides a description of what activity is being measured.
    • Link to FAQ – Quick link at the bottom of the page takes you to common questions about the instances.
    • New instance support link – Instead of taking you to the thread creation form for the instance help section, the link now takes you to the Instance Help space on the Developer Community.  We did this since there were so many repeat questions.
  • Plugin Activation – Also on the My Instance page under the action menu, activates plugins that traditionally only ServiceNow Support has access.  All of these were requested through feedback and permission granted by the plugin owner. We have added several new plugins that you can activate through self-service:
    • Domain Support - Domain Extensions InstallerMy Instance Screen.png
    • ECC Queue Retry Policy
    • Event Management
    • Many to many task relations
    • Orchestration - Examples
    • Orchestration Activities - EC2
    • Orchestration Activities - Puppet
    • Orchestration Virtualization
    • Orchestration - Amazon EC2
    • Orchestration Activities - Chef
    • Orchestration - VMware Support
    • Orchestration Activities - VMware
    • Orchestration Virtualization Core Components
    • Performance Analytics - Premium and all content packs
    • Password Reset - Orchestration Add-on
  • Course Navigation – First tested on the API reference, by popular demand, courses now have a sticky left navigation pane that scrolls independently of the content.  We will be extending this to documentation next.

 

Stay tuned: (What’s on the horizon)

  • Upgrades to new patch versions both automated and self-service through the My Instance page, Action menu
  • New courses – Advanced UI and Native Platform Features are in the design stages and getting resourced by the documentation team
  • More APIs – Docs team working hard at making the site the one stop reference to all platform APIs
  • And many more cool features …

 

Please use the feedback forms on the developer site to tell us what you think, or comment below.  We are trying to make this site an indispensable part of your daily routine and we need your direct input to help us do that.  We are listening.

 

Regards,

CreateNow Team

One of the most common things that developers and support engineers encounter is troubleshooting why certain things are not working as expected. Having decent debugging tools and strategies to assist you identify the cause can be the difference between 12 hours of troubleshooting and an hour of debugging. ServiceNow offers several debugging tools that can help you determine the cause of strife.


When you enable any of the ServiceNow debugging options, it will only do work on your current browser sessions. Hence, it is safe to enable them without worrying that it might affect other users on the system.

Screen Shot 2015-05-28 at 9.45.17 AM.JPG

 

 

If you are not sure which debug to turn on, you can try the "Enable All" and get yourself familiar with the options. To end the debugging, click on the "Disable All" or logout the session.

 

5 Debugging Strategies

There are several debugging strategies that developers use. Debugging strategies that work for one developer or support engineer may not necessarily work for another. You can use a combination of debugging tools to find the best way to decipher the issue occurring on your instance.

 

Brainstorm a Hypothesis

Everyone has theories about various things. There is a saying "if you are a hammer, everything looks like a nail." One of the most common pitfalls of debugging is having the wrong assumption. From my experience, the most difficult cases are most likely caused by an innocent change that goes over looked. Hence, it is necessary to brainstorm a list of possible hypothesis and rule them out one-by-one before proceeding.

 

Rule out the hypothesis

For each hypothesis, the general approach is to design some experiments and test them out. To do this properly, it is better to stick with the same test case and avoid too much variations. The idea is to test the hypothesis without creating unnecessary variations to the problem. However, we may have a long list of hypotheses, ruling them out one-by-one may be time consuming. This is where a "Divide and Conquer" approach would save your team a lot of time.

 

Divide and Conquer

There are various way to divide hypotheses and test cases. Generally for ServiceNow, there could be two possible causes that lead to the problem:

  • A bug with a ServiceNow out-of-box feature.
  • A mistake with the customization.

 

If it is a product issue (bug), then there would not be any need to waste more time troubleshooting the issue. Isolating the case would make it easier for ServiceNow Support to help troubleshoot.

 

Isolate the case

To speed up the troubleshooting process and to help the ServiceNow Support productively, it is better to create a simple isolation case to replicate the issue. If the issue can be replicated with the simple case, you can use the steps for replication to lodge a Support incident for ServiceNow Support to investigate.

 

 

Example:

Here is an example of a problem which can could be replicated. In this case, whenever I updated the Requested Item, something weird happens. I turned on the debug and I can see something weird:

 

Screen Shot 2015-06-01 at 10.14.24 AM.JPG

 

The "==>" and "<==" signifies a "Business Rule" call. In this case, the name of the business rule is "FunnyBusinessRule".

When the "Log" is checked, we could see more information of the messages from the Business Rule "FunnyBusinessRule".

 

Screen Shot 2015-06-01 at 10.12.19 AM.JPG

 

Looking at the list of business rule, we can see that it is custom business rule created by the user "Huey" and that it was recently updated.

Screen Shot 2015-06-01 at 10.20.15 AM.JPG

 

If deactivating the business rule makes the problem go away, then we can be sure that the business rule is causing the issue. In this case, it is a customization issue and not an out-of-box issue.

 

Do a review of the business rule and try to understand why it is there in the first place. There might be a need to approach the developer/contractor who create or last updated the business rule.

 

If the issue cannot be replicated with the simple case, then there must be something else causing the issue. Either the steps to replicate are insufficient or there is a customization causing the issue. Reevaluate the hypothesis again and repeat the debugging process cycle from the beginning again.

 

Get Support involved

Having a simple isolated case is helpful not only for yourself but for anyone whom you are approaching for help. There are various places to seek clarifications regarding the features before you approach ServiceNow Support for assistance. Sharing your case in the community is a good starting point. If the community is unable to guide you to your solution, Support may be needed.

 

To help ServiceNow Support in assisting you more efficiently, some information are appreciated when reporting your issue:

  • Steps to reproduce
  • Screen Shots
  • Expected result
  • Observations (if any).
  • Affected instance/platform (if relevant)
  • Impact (how the issue is impacting your instance/company)
  • Workaround (if any)

 

Debugging is a creative and patience process, the ServiceNow debugging options are just the tools. At times, it might seem like a nightmare trying to find out "what you did last summer" or trying to find out who took away the kettle (from "Polly puts the kettle on"). Think of the whole process as a treasure hunt game and hopefully that helps.

 

For more information see

Debugging Tools Best Practices

JavaScript Debug Window

Search "debug" and related search terms on the community

ServiceNow ShareNow Portal

Hi Knowledge Base (requires Hi login)

 

Meanwhile, happy debugging

The Knowledge Base is kept current with frequent edits and additions. Find out what is new and stay up-to-date on the latest ServiceNow Knowledge Base articles by reviewing the weekly KB digest.user interface.jpg

 

 

 

Recently added and updated articles on User Interface:

 

 

User Interface (UI)


Customize, personalize and manage the way users view and interact with your organization or company’s interface using UI. (Click to see all User Interface Knowledge Base articles)

Filter Blog

By date: By tag: