Skip navigation
1 2 Previous Next

Developer Community

21 Posts authored by: Jim Coyne

Other posts related to Themes

"Helsinki Gray" UI16 Theme

Istanbul Theme Properties Visual Guide

Jakarta Theme Properties Visual Guide

 

We are talking about Themes once again in this post, this time for the Kingston release.

 

Test Theme Record

Here is everyone's favorite Theme record, updated for Kingston:

 

/* Kingston Test
    Created by Jim Coyne - https://community.servicenow.com/people/jim.coyne

    This is to help show what elements are affected by the CSS colors - PLEASE, PLEASE, PLEASE DO NOT ACTUALLY USE THIS THEME FOR REAL  :-)
    It uses HTML color names to hopefully make it a little easier to understand and find the color

    The comments include a copy of the UI16 default value for Kingston:
        https://docs.servicenow.com/bundle/kingston-servicenow-platform/page/administer/navigation-and-ui/reference/r_DefaultCSSStyle.html

    Refer to this post for more information:
        https://community.servicenow.com/community/develop/blog/2017/11/22/kingston-theme-properties-visual-guide
*/

/* Mostly Banner */
$navpage-header-bg: DodgerBlue  /* #303a46 - banner background  */
$navpage-header-color: Aqua  /*  #ffffff - banner title text  */
$navpage-header-button-color: Coral /*  no default, not documented - logged-in user name + Connect, Help and Settings icons   */
$navpage-header-divider-color: FireBrick  /*  #455464 - banner separator line  */
$navpage-button-color: BlueViolet  /*  #fff - Update Set and Application icons + Navigator icons + Connect icons  */
$navpage-button-color-hover: Yellow  /*  #7EC24F - banner icons + clear search text icons + Navigator buttons when clicked  */


/* Mostly Navigator */
$navpage-nav-bg: BurlyWood  /*  #303a46 -  Navigator and Sidebar header and footers + unselected Navigator and Connect tabs background + History time separator background  */
$navpage-nav-bg-sub: Pink  /*  #455464 - Navigator and Sidebar backgrounds + background for Applications, Favorites and History entries  */
$nav-highlight-main: LightSkyBlue  /*  #3D4853  - Module, Favorite, History, Connect and Help item when clicked  */
$subnav-background-color: SlateGray  /*  #455464 - Module background  */
$navpage-nav-app-text: Black /*  #cfd4d8 - Application, Favorite and History text + Connect and Help text  */
$navpage-nav-color-sub: Tomato  /*  #bec1c6 - Module text  */
$navpage-nav-app-text-hover: DarkTurquoise   /*  no default, not documented - Selected Module, Favorite, History, Connect and Help item text  */
$navpage-nav-selected-bg: Olive  /*  #4B545F - Selected Navigator and Connect tab background */
$navpage-nav-selected-color: OrangeRed  /*  #ffffff - Active Navigator and Connect tab icons  */
$navpage-nav-unselected-color: Orange  /*  #bec1c6 - Inactive Navigator and Connect tab icons  */
$navpage-nav-border: Magenta  /*  #ddd - Global Search, Navigator and Connect search box outlines + search box filter icons  */
$nav-hr-color: YellowGreen  /* #303a46 - Separator modules without a label + Vertical separator line between main frame and Navigator/Sidebars  */
$nav-highlight-bar-active: Red  /*  #278efc - Highlight line under active Navigator/Connect tabs + selected Connect, Help or Settings icon + number of Connect messages dot  */
$nav-highlight-bar-inactive: PaleGoldenRod  /*  #828890 - Highlight line under inactive Navigator/Connect tabs  */


/* Search text */
$search-text-color: LightGreen  /*  #e7e9eb - Search text + clear search text icons + Navigator bar filter icon when minimized  */


/* unknown properties, listed as a default on the docs site  */
$connect-latest-message: Violet  /*  #cfd4d8  */

 

Just like the previous test Themes, it is not meant for actual use, but to help point out what properties affect what controls.

 

I used the default values from the "Default CSS styles for UI16" section from the Default CSS styles article on the docs site to build the Theme.  Below is a list of the individual properties with screenshots to show the affected controls/areas, which appear in yellow.

 

I've also listed any changes from Jakarta as well as some note/comments/opinions.

 

$navpage-header-bg - #303a46

  • Banner frame background

 

 

$navpage-header-color - #ffffff

  • Banner frame title text
  • Domain picker icon

Change from Jakarta:

  • Global Search icon no longer uses the property

 

Notes:

  • Domain picker icon should be using "$navpage-header-button-color" instead for consistency

 

 

$navpage-header-button-color (#ffffff, not listed in the Default CSS styles article)

  • Logged-in user name text
  • OpenFrame (phone), Global Search (magnifying glass), Connect (text bubbles), Help (question mark) and Settings (gear) icons
  • Xplore: Developer Toolkit icon (eyeglasses) (see note below)

Changes from Jakarta:

  • Global Search icon uses this property now

 

Notes:

  • almost there - only need the Update Set, Application and Domain picker icons to use it now for consistency
  • The Xplore: Developer Toolkit is an excellent third-party tool from James.Neale and company, available on Share

 

 

$navpage-header-divider-color - #455464

  • Banner frame separator line

 

 

$navpage-button-color - #ffffff

  • Update Set and Application icons
  • Minimize Navigator and Edit Favorites icons
  • Create a New Conversation, Open Connect standalone interface and Close Connect Sidebar icons

Notes:

  • Update Set and Application icons should be using "$navpage-header-button-color" instead for consistency

 

 

$navpage-button-color-hover - #7ec24F

  • Update Set, Application, Global Search, Connect, Help and Settings icons when cursor is over the controls (only the Global Search icon is highlighted in the first screenshot below but the others will highlight when the cursor is over them)
  • Clear search text icon when cursor is over the control in Navigator and Connect sidebar
  • Navigator bar icons when clicked (some browsers [e.g. Chrome] only remove the highlight after cursor is clicked elsewhere)

Notes:

  • the Domain picker icon does not actually do anything so there's no change when hovering over it

 

 

$navpage-nav-bg - #303a46

  • Navigator, Connect and Help Sidebar header and footers
  • Unselected Navigator and Connect Sidebar tab backgrounds
  • Connect Sidebar section headers
  • History time separator background

 

 

$navpage-nav-bg-sub - #455464

  • Navigator, Connect and Help Sidebar backgrounds
  • Background for Applications, Favorites and History entries
  • Selected icon when editing a Favorite

 

 

$nav-highlight-main - #3D4853

  • Module/Favorite (not in Safari)/History item when clicked (each browser has its own quirks with this one - Safari only shows while clicking the item, others will keep the highlight a second or so)
  • Selected Connect item (remains highlighted until another is selected or another record's chat window is selected or the record's chat window is closed)

 

Notes:

  • Help item is no longer highlighted (shown differently now in Kingston)

 

 

$subnav-background-color - #455464

  • Module background

 

 

$navpage-nav-app-text - #cfd4d8

  • Application title text
  • Separator Module icon
  • "Loading..." Navigator message
  • Favorites text
  • Delete Favorite icon
  • History time separator text
  • History items text
  • Connect message text
  • Connect informational text
  • Help Sidebar title and context menu icon

Notes:

  • Edit Application and Add to Favorites icons no longer use this property

 

 

$navpage-nav-color-sub - #bec1c6

  • Module text
  • Favorite icon
  • Edit Module and Add To Favorites icons when hovering over them

 

 

$navpage-nav-app-text-hover (unknown default, not listed in the Default CSS styles article)

  • Module text, Edit Module and Add To Favorites icons when Module is selected/clicked
  • Favorite text and Delete Favorite icon when Favorite is selected/clicked
  • History text, Connect message
  • First Module that matches a Navigator search

Notes:

  • Help item text when selected/clicked no longer uses this property (Help works differently in Kingston)

 

 

$navpage-nav-selected-bg - #4b545F

  • Active Navigator tab background (Apps, Favorites or History)
  • Active Connect tab background (Chat or Support)

 

 

$navpage-nav-selected-color - #ffffff

  • Active Navigator tab icon (Apps, Favorites or History)
  • Active Connect tab icon (Chat or Support)

 

 

$navpage-nav-unselected-color - #bec1c6

  • Inactive Navigator tab icons (Apps, Favorites or History)
  • Inactive Connect tab icons (Chat or Support)

 

 

$nav-highlight-bar-active - #278efc

  • Highlight line under active Navigator tab (Apps, Favorites or History)
  • Highlight line under active Connect tab (Chat or Support)
  • Navigator and Connect search box outlines when selected
  • Selected Connect, Help or Settings icon (only the Connect icon is highlighted in the screenshot below but the others will highlight when clicked/selected)
  • Number of Connect messages dot
  • Outline of logged-in user control when selected

 

 

$nav-highlight-bar-inactive - #828890

  • Line under inactive Navigator tabs
  • Line under inactive Connect tabs

 

 

$nav-hr-color - #303a46

  • Separator modules without a label
  • Vertical separator line between main frame and Navigator/Sidebars

 

 

$navpage-nav-border - #dddddd

  • Global Search, Navigator and Connect search box outlines
  • Navigator and Connect search box filter icons
  • Outline of logged-in user control when selecting a drop-down menu item

 

 

$search-text-color - #e7e9eb

  • Global Search, Navigator and Connect search text
  • Clear search text icon in Navigator and Connect search boxes
  • Navigator bar filter icon when minimized

 

 

Updates

I'll try to keep this post updated with anything new that I find.  Please let me know if I've missed anything, or if something is incorrect.  I started this article based on the Jakarta one, so please forgive any copy/paste errors (but let me know about any).  Thanks in advance.

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

It's always a good idea to setup your different instances with unique color schemes so you can quickly identify which one you are in.  Very useful, obviously, for developers and admins who are jumping around between the different instances all the time.

 

However, sometimes your training or documentation teams need to take screenshots of a sub-production instance in order to document some new feature before release and they want to use the same colors as production because, well, that's the one your users will be using.

 

Instead of having to bug your admins to temporarily change the colors in the sub-prod instance and confuse everyone, just create a Theme record with the same colors as production.  All that is needed in the CSS field is the particular variables/properties that you've changed in production from the standard OOB values.  Here's an example Theme I setup for a client where we simply changed the strip of color just under the banner to match their corporate colors:

 

/* Theme to simulate production colors for documentation purposes */
/* Remember the Clone Data Preserver if you change the name of the Theme */

$navpage-header-divider-color:  #00467f

 

I created the Theme record as well as a Clone Data Preserver to preserve the sub-production versions of the record because I then set the record to inactive in production so it does not appear in the list of themes to choose from (would be a little weird).

 

Now your training and documentation teams can switch at will without affecting everyone else.

 

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

Jim Coyne

"Switch to List View" Tool

Posted by Jim Coyne Aug 1, 2017

Here is "Switch to List View".  It's a "Form context menu" UI Action that simply switches to the list view for the table, and filters the list to only display the current record:

 

 

 

It's useful, for instance, when you need to see or modify a field that is not, for whatever reason, displayed on the form view.  You can personalize your list view, add the appropriate fields and update the record if you need to.

 

UI Action details:

Name: Switch to List View

Table: Global [global]

Order: 200,000

Active: checked

Show insert: checked

Show update: checked

Client: checked

Form context menu: checked

Hint: Switches to the List View for the table, returning this one record

Onclick: u_switchToListView()

Condition: gs.hasRole("admin")

Script:

function u_switchToListView(){
    try{
        window.location = "/" + g_form.getTableName() + "_list.do?sysparm_query=sys_id%3d" + g_form.getUniqueValue();
    } catch(err){}
}

 

 

I've attached the XML export of my UI Action record if you want to just import that.  Try it out in a personal dev instance first.

 

Related Posts:

"Show Contents of g_scratchpad" Tool

"Try It (Portal)" Tool

"Developer Toolbox" Tool

"Preview GlideRecord Script" Tool

"Preview in Background Script" Tool

"Xplore GlideRecord Script" Tool

"View Data to Preserve" Tool

"Create Module From Query" Tool

"Clear User Settings" Tool

"Grab Grouped Information" Tool

Showing a Schema Map From a List View

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

We are adding quite a bit of information to the g_scratchpad object on a project I'm involved with at the moment so I decided to create a quick tool to help us see what all ends up there.  It's a simple client-side Related Link UI Action that pops up a window with the current contents:

 

 

1. Here's the configuration for the UI Action:

Name: Show Contents of g_scratchpad

Table: Global

Order: 100,000

Action name: u_show_g_scratchpad

Active: checked

Show insert: checked

Show update: checked

Client: checked

Form link: checked

Hint: Displays the contents of the g_scratchpad object in a popup window

Onclick: u_showGScratchpad()

Condition: gs.hasRole("admin")

Script:

function u_showGScratchpad(){
    var newLine = "~~~newline~~~";  //will be replaced with line breaks in the UI Page
    var scratchPad = "";
    var items = Object.keys(g_scratchpad);
    items.sort();  //sort the item names alphabetically in case they are not already

    var numberOfItems = items.length;
    for (var i = 0; i < numberOfItems; i++) {
        scratchPad += items[i] + " = " + JSON.stringify(g_scratchpad[items[i]]) + newLine;
    }

    //encode the string so it can be passed to the UI Page properly and then decoded there
    scratchPad = encodeURIComponent(scratchPad);

    //open the dialog window
    var gdw = new GlideDialogWindow("u_simple_copy_paste");
    gdw.setTitle("Contents of g_scratchpad");
    gdw.setSize(650, 500);
    gdw.setPreference("sysparm_text", scratchPad);
    gdw.render();
}

 

 

2. The pop-up UI Page:

Name: u_simple_copy_paste

Category: General

HTML:

<textarea id="u_text_area" style="width: auto; height: auto;" rows='15' cols='100' title="Text you can copy and paste">
</textarea>
<div align="right">
<button class="btn btn-default" id="cancel_button" onclick="(window.GlideDialogWindow || window.GlideModalForm).prototype.locate(this).destroy(); return false" style="min-width: 5em;" title="" type="button">Close</button>
</div>

 

Client script:

try {  
  var search = "~~~newline~~~";  //text we want to replace  
  var replace = "\n";  //the text we want to use  
  var textArea = gel("u_text_area");  
  //set the text string into the text area control, first decoding it and replacing the search string with the replacement string to insert proper line breaks  
  textArea.innerHTML = (decodeURIComponent("${sysparm_text}")).replace(new RegExp(search, 'g'), replace);  
  //auto-select the entire text  
  textArea.select();  
} catch(err) {}

 

The UI Page is the same one used by "Preview GlideRecord Script" Tool  and "Grab Grouped Information" Tool.  This one is slightly updated - I've added a "Close" button to the form.  You can use the existing UI Page as is if you are using either of the other two tools, or update the HTML field with the code above to add the button.

 

I've attached the XML files for both the UI Action and the UI Page if you want to just import them into your instance.

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

Other posts related to Themes

"Helsinki Gray" UI16 Theme

Istanbul Theme Properties Visual Guide

Kingston Theme Properties Visual Guide

 

As a follow-up to my Istanbul Theme Properties Visual Guide post, this one describes the Theme properties for UI16 in the Jakarta release.

 

Test Theme Record

Here's the return of the ugly Theme record, updated for Jakarta:

 

/* Jakarta Test
    Created by Jim Coyne - https://community.servicenow.com/people/jim.coyne

    This is to help show what elements are affected by the CSS colors - PLEASE, PLEASE, PLEASE DO NOT ACTUALLY USE THIS THEME FOR REAL  :-)
    It uses HTML color names to hopefully make it a little easier to understand and find the color

    The comments include a copy of the UI16 default value:
        https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/administer/navigation-and-ui/reference/r_DefaultCSSStyle.html

    Refer to this post for more information:
        https://community.servicenow.com/community/develop/blog/2017/07/19/jakarta-theme-properties-visual-guide
*/

/* Mostly Banner */
$navpage-header-bg: DodgerBlue  /* #303a46 - banner background  */
$navpage-header-color: Aqua  /*  #ffffff - banner title text  */
$navpage-header-button-color: Coral /*  no default, not documented - logged-in user name + Connect, Help and Settings icons   */
$navpage-header-divider-color: FireBrick  /*  #455464 - banner separator line  */
$navpage-button-color: BlueViolet  /*  #fff - Update Set and Application icons + Navigator icons + Connect icons  */
$navpage-button-color-hover: Yellow  /*  #7EC24F - banner icons + clear search text icons + Navigator buttons when clicked  */


/* Mostly Navigator */
$navpage-nav-bg: BurlyWood  /*  #303a46 -  Navigator and Sidebar header and footers + unselected Navigator and Connect tabs background + History time separator background  */
$navpage-nav-bg-sub: Pink  /*  #455464 - Navigator and Sidebar backgrounds + background for Applications, Favorites and History entries  */
$nav-highlight-main: LightSkyBlue  /*  #3D4853  - Module, Favorite, History, Connect and Help item when clicked    */
$subnav-background-color: SlateGray  /*  #455464 - Module background  */
$navpage-nav-app-text: Black /*  #cfd4d8 - Application, Favorite and History text + Connect and Help text  */
$navpage-nav-color-sub: Tomato  /*  #bec1c6 - Module text  */
$navpage-nav-app-text-hover: DarkTurquoise   /*  #ffffff - Selected Module, Favorite, History, Connect and Help item text  */
$navpage-nav-selected-bg: Olive  /*  #4B545F - Selected Navigator and Connect tab background */
$navpage-nav-selected-color: OrangeRed  /*  #ffffff - Active Navigator and Connect tab icons  */
$navpage-nav-unselected-color: Orange  /*  #bec1c6 - Inactive Navigator and Connect tab icons  */
$navpage-nav-border: Magenta  /*  #ddd - Global Search, Navigator and Connect search box outlines + search box filter icons  */
$nav-hr-color: YellowGreen  /* #303a46 - Separator modules without a label + Vertical separator line between main frame and Navigator/Sidebars  */
$nav-highlight-bar-active: Red  /*  #278efc - Highlight line under active Navigator/Connect tabs + selected Connect, Help or Settings icon + number of Connect messages dot  */
$nav-highlight-bar-inactive: PaleGoldenRod  /*  #828890 - Highlight line under inactive Navigator/Connect tabs  */


/* Search text */
$search-text-color: LightGreen  /*  #e7e9eb - Search text + clear search text icons + Navigator bar filter icon when minimized  */


$connect-latest-message: Violet  /*  #cfd4d8 - no idea, not able to see it  */

 

 

Just like the previous test Themes, it is not meant for actual use, but to help point out what properties affect what controls.

 

I used the default values from the "Default CSS styles for UI16" section from the Default CSS styles article on the docs site to build the Theme.  Here is a list of the individual properties with screenshots to show the affected controls/areas, which appear in yellow.

 

 

$navpage-header-bg - #303a46

  • Banner frame background

 

 

$navpage-header-color - #ffffff

  • Banner frame title text
  • Domain picker icon
  • Global Search icon

 

 

$navpage-header-button-color (unknown default, not listed in the Default CSS styles article)

  • Logged-in user name text
  • Connect, Help and Settings icons

 

 

$navpage-header-divider-color - #455464

  • Banner frame separator line

 

 

$navpage-button-color - #ffffff

  • Update Set and Application icons
  • Minimize Navigator and Edit Favorites icons
  • Create a New Conversation, Open Connect standalone interface and Close Connect Sidebar icons

 

 

$navpage-button-color-hover - #7ec24F

  • Update Set, Application, Global Search, Connect, Help and Settings icons when cursor is over the controls (only the Global Search icon is highlighted in the first screenshot below but the others will highlight when the cursor is over them)
  • Clear search text icon when cursor is over the control in Navigator and Connect sidebar
  • Navigator bar icons when clicked (some browsers [e.g. Chrome] only remove the highlight after cursor is clicked elsewhere)

 

 

$navpage-nav-bg - #303a46

  • Navigator, Connect and Help Sidebar header and footers
  • Unselected Navigator and Connect tabs background
  • History time separator background

 

 

 

$navpage-nav-bg-sub - #455464

  • Navigator, Connect and Help Sidebar backgrounds
  • Background for Applications, Favorites and History entries
  • Selected icon when editing a Favorite

 

 

$nav-highlight-main - #3D4853

  • Module/Favorite (not in Safari)/History/Help item when clicked (each browser has its own quirks with this one - Safari only shows while clicking the item, others will keep the highlight a second or so, and some keep the Help item highlighted until the cursor is clicked elsewhere)
  • Selected Connect item (remains highlighted until another is selected or another record's chat window is selected or the record's chat window is closed)

        

   

 

 

$subnav-background-color - #455464

  • Module background

 

 

$navpage-nav-color-sub - #bec1c6

  • Module text
  • Edit Module and Add To Favorites icons

 

 

 

$navpage-nav-app-text - #cfd4d8

  • Application title text
  • Edit Application and Add to Favorites icons
  • "Loading..." Navigator message
  • Favorites text
  • Delete Favorite icon
  • History time separator text
  • History items text
  • Connect message text
  • Connect informational text
  • Help sidebar title and items text

        

        

 

 

$navpage-nav-app-text-hover (unknown default, not listed in the Default CSS styles article)

  • Module text, Edit Module and Add To Favorites icons when Module is selected/clicked
  • Favorite text and Delete Favorite icon when Favorite is selected/clicked
  • History text, Connect message and Help item text when selected/clicked
  • First Module that matches a Navigator search

 

 

$navpage-nav-selected-bg - #4b545F

  • Active Navigator tab background (Apps, Favorites or History)
  • Active Connect tab background (Chat or Support)

 

 

$navpage-nav-selected-color - #ffffff

  • Active Navigator tab icon (Apps, Favorites or History)
  • Active Connect tab icon (Chat or Support)

 

 

$navpage-nav-unselected-color - #bec1c6

  • Inactive Navigator tab icons (Apps, Favorites or History)
  • Inactive Connect tab icons (Chat or Support)

 

 

$nav-highlight-bar-active - #278efc

  • Highlight line under active Navigator tab (Apps, Favorites or History)
  • Highlight line under active Connect tab (Chat or Support)
  • Selected Connect, Help or Settings icon (only the Connect icon is highlighted in the screenshot below but the others will highlight when clicked/selected)
  • Number of Connect messages dot
  • Outline of logged-in user control when selected

   

   

 

 

$nav-highlight-bar-inactive - #828890

  • Line under inactive Navigator tabs
  • Line under inactive Connect tabs

 

$nav-hr-color - #303a46

  • Separator modules without a label
  • Vertical separator line between main frame and Navigator/Sidebars

 

 

$navpage-nav-border - #dddddd

  • Global Search, Navigator and Connect search box outlines
  • Navigator and Connect search box filter icons
  • Outline of logged-in user control when selecting a drop-down menu item

 

 

$search-text-color - #e7e9eb

  • Global Search, Navigator and Connect search text
  • Clear search text icon in Navigator and Connect search boxes
  • Navigator bar filter icon when minimized

 

 

 

Updates

I'll try to keep this post updated with anything new that I find.  Please let me know if I've missed anything, or if something is incorrect.  Thanks in advance.

 

 

Updated Sunday, December 10, 2017

  • added "First Module that matches a Navigator search" to the "$navpage-nav-app-text-hover" property

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

I don't like using a real user's credentials when setting up a new Remote Instance (or Update Source) record:

 

 

This can become a problem when the user changes their password or changes positions internally or even leaves the company entirely.  You would then have to change the Remote Instance record for each of your instances.  Usually the person who creates the record ends up using their own credentials because it's easier and faster to do so, but it's not the best way.  Creating a new user and assigning them the "admin" or "teamdev_user" roles just gives them more access than what is needed. Creating a service account with just the right access will save you from future headaches.  For more information about service accounts, see this post - User account or service account? What to use for web service tasks.

 

Spoiler alert - I've attached an Update Set XML export to save you from creating the records manually, but wanted to describe what needs to be done anyways.

 

I create a new User record with the following details:

User ID - #update.sets.integration

First name - Update Sets

Last name - Integration

Password - follow your established security rules to create a secure password

Active - checked

Web service access only - checked (important)

 

Checking the "Web service access only" check box will only allow that "user" to login to the instance using API calls and not into the regular user interface.

 

The next thing to do is create a new Role called "u_update_sets_integration".  Once you save the new record, add the "soap_query" Role as a Contained Role so that users with the new Role will inherit the "soap_query" Role as well:

 

 

Once you do that, assign the new Role to the "Update Sets Integration" user:

 

Next, you need to assign the "u_update_sets_integration" Role to two different Access Control records, one each for the "sys_update_set" and "sys_update_xml" tables.  You can use the following URL to find the appropriate ones (change "instancename" to your own name of course):

https://instancename.service-now.com/sys_security_acl_list.do?sysparm_query=GOTOname%3Dsys_update_set%5EORname%3Dsys_upd…

 

You need to add the "u_update_sets_integration" Role to the Requires Role Related List for both of the Access Control records:

 

The last thing you need to do is update the Remote Instance record with the new credentials.  There will, however, be an issue when you try to save it:

 

ServiceNow will validate the credentials are correct and will verify what roles the user has in the remote instance instead of verifying if it can perform the required operations.  So you will have to temporarily give the Update Sets Integration User the "teamdev_user" role.  You can remove it once the Remote Instance record has been updated.

 

So now you have a user with just the right amount of access to import your Update Sets and it should not count as a licensed user (always check with your ServiceNow sales rep).  Obviously performing all these steps manually does not make sense and would negate any gains this would give you so you should use the attached Update Set XML file instead.  Import it into your personal dev instance to see all the records that are created and feel comfortable with the changes before adding it to your instances.

 

And don't forget to change the password for the new User record if you import the attached XML file (it is blank in the Update Set).

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

Jim Coyne

"Try It (Portal)" Tool

Posted by Jim Coyne May 4, 2017

Here's "Try It (Portal)", a new tool in my useful tools series.  It's a "Form button" UI Action that will open up a new tab/window and load the current catalog item within the Service Portal:

_Screenshot.png

It's very similar to the OOB "Try It" UI Action that redirects the current window to the catalog item, but this one will open the Service Portal in a new tab/window for you.  There's nothing really special about it, but it saves you from loading the portal and trying to find it in order to test it out.

 

UI Action details:

Name: Try It (Portal)

Table: Catalog Item [sc_cat_item]

Order: 100

Action name: u_try_it_portal

Active: checked

Show update: checked

Form button: checked

Client: checked

Onclick: u_tryInPortal()

Hint: View this item within the Service Portal (opens a new tab/window)

Condition: current.active == true && new CatalogItemTypeProcessor().canTryIt(current.getRecordClassName()) && !(current.getRecordClassName() == "sc_cat_item_content" && current.content_type == "external")

 

Script:

function u_tryInPortal(){
  //view this item within the Service Portal in a new tab/window
  window.open("sp?id=sc_cat_item&sys_id=" + g_form.getUniqueValue(), "_blank");
}

 

If your Service Portal has a different URL suffix, just change the "sp" on line 3 to whatever is appropriate for your instance.

 

The condition is basically the same as the OOB "Try It" UI Action except I removed "current.canWrite()" because this UI Action is not performing a save.

 

I've attached an XML export of my UI Action record if you want to just import that.  Try it out in a personal dev instance first.

 

Related Posts:

"Developer Toolbox" Tool

"Preview GlideRecord Script" Tool

"Preview in Background Script" Tool

"Xplore GlideRecord Script" Tool

"View Data to Preserve" Tool

"Create Module From Query" Tool

"Clear User Settings" Tool

"Grab Grouped Information" Tool

Showing a Schema Map From a List View

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

It's always a good idea to write and maintain the minimum amount of code as possible, so minimizing the number of Email Scripts is helpful.  But can we have just one script AND output different content based on the target audience of the notification?  You want to stay away from writing different scripts to output slightly different text, like an additional field for example, based on the target audience.  Email Scripts do not support passing parameters, which would be helpful in this scenario, but we can get around that by adding the parameter on the Notification record instead, which is where you define your target audience anyways.

 

First, add a new field on the Notification form:

It can be as simple as a string field or you can create a Choice List for it as well.

 

Create the Mail Script that will contain the text you want to output as well as the logic for supporting slightly different text:

My example is not very useful, but you get the idea.

 

And lastly, in the Notification record, call the Mail Script from within the HTML field:

Depending on your own use case, you could even create an Email Template that contains the default text and the call to the Mail Script to really keep maintenance to a minimum.

 

So when the Email Script is run, it will check the field on the Notification record and output different text based on that value.  Here's a preview of 3 different Notifications I created, all using the same Email Script, but with different values in the Custom parameter field.  They all output something different from that 1 script.

 

First Notification:

 

Second:

 

Third:

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

Other posts related to Themes

"Helsinki Gray" UI16 Theme

Jakarta Theme Properties Visual Guide

Kingston Theme Properties Visual Guide

 

In a previous post, "Helsinki Gray" UI16 Theme, I wrote about a new Theme I designed for Helsinki.  I tried to reproduce the look in Istanbul but ran into some issues because of changes to how the Theme properties are used on the controls.  So I spent some time trying to understand which properties set the color of what controls.  Took awhile to do and decided to share what I found here.

 

Test Theme Record

While trying to figure everything out, I created a new test Theme called "Istanbul Test", similar to the one I created for Helsinki:

 

I realize it's ugly.  Really ugly, but I made it that way in order for the different controls to stand out from each other, so it did have to be kinda crazy looking.  I used the standard HTML color names to make it easier to spot where they are used.  Here's the CSS for it:

 

/* Istanbul Test
    Created by Jim Coyne - https://community.servicenow.com/people/jim.coyne

    This is to help show what elements are affected by the CSS colors - PLEASE, PLEASE, PLEASE DO NOT ACTUALLY USE THIS THEME FOR REAL  :-)
    It uses HTML color names to hopefully make it a little easier to understand and find the color

    The comments include a copy of the UI16 default value:
        https://docs.servicenow.com/bundle/istanbul-servicenow-platform/page/administer/navigation-and-ui/reference/r_DefaultCSSStyle.html
    I've added my own comments within () to hopefully clarify what is affected by the color
*/

/* Header Colors */
$navpage-header-bg: DodgerBlue  /* #303a46  Topbar background color (the banner) */
$navpage-header-color: Aqua /* #ffffff  Topbar text color and history hover color (Banner title text, Global Search + Application + Update Set icon outlines) */
$navpage-header-button-color: Coral /* (Logged-in user name text + Connect, Help and Settings icons) */
$navpage-header-divider-color: FireBrick /* #455464  Bottom border color on topbar (banner separator line) */
$navpage-button-color: BlueViolet /* #ffffff  Default button/icon colors  (Nav bar [maximized] buttons, Favorite and History 1st line text, Connect msg record display value and Create a new converstaion icon) */
$navpage-button-color-hover: Yellow /* #7ec24F  Topbar buttons hover color (Global Search, Connect, Help and Gear icons hover + clear search text icon hover + selected Nav bar icon [temporary effect only]) */

/* Search Colours */
$search-text-color: LightGreen /* #e7e9eb  Search text color (+ clear search text icon + Nav bar [minimized] buttons) */
$navpage-nav-border: Magenta  /* #dddddd  Color of outline for search (Global, Nav and Connect search box outlines + outline of logged-in user control when selected) */

/* Left nav and navigation toolbar background color */
$nav-highlight-main: LightSkyBlue /* #3D4853  Navigator hover color (Last Module/Favorite/History/Connect/Help item selected [temporary effect only]) */
$subnav-background-color: SlateGray /* #455464  Background for expanded navigation items (NO IDEA) */
$navpage-nav-bg: BurlyWood /* #303a46  Background for navigator (left side only). (Nav bar, Connect bar and Module backgrounds + History separators) */
$navpage-nav-bg-sub: Pink /* #455464  Background for Favorites list, history list, and Connect list background. (background for Apps/Favorites/History and Connect/Help bars and selected icon when editing a favorite) */
$navpage-nav-color-sub: Tomato  /* #bec1c6  Text color in main navigation (NO IDEA) */
$navpage-nav-mod-text-hover: Purple /* #ffffff  Text color when hovering over items in main nav (NO IDEA) */
$nav-hr-color: YellowGreen /* #303a46  Divider color in Navigator (Separator module [ones without a label]) */

/* Navigator tabs */
$nav-highlight-bar-active: Red /* #278efc  Active nav item underneath search (thin line under selected Apps, Favorites or History icons, selected Connect, Help or Gear icon + number of Connect msgs dot)  */
$nav-highlight-bar-inactive: PaleGoldenRod  /* #828890  Inactive nav items underneath search (thin line under Apps, Favorites or History icon when not selected) */
$navpage-nav-selected-bg: Olive /* #4b545F  Background for currently selected navigation item underneath search (background for selected Apps, Favorites or History icon) */
$navpage-nav-selected-color: OrangeRed /* #ffffff  Color of icon for currently active nav item. (Apps, Favorites or History icon when  selected) */
$navpage-nav-unselected-color: Orange  /* #bec1c6  Color of icons for non inactive nav items. (Apps, Favorites or History icon when not selected and Module title text)  */

/* Navigator Application text */
$connect-latest-message: White  /* #cfd4d8  Color for latest connect messages in right bar. (NO IDEA) */
$nav-timeago-header-color: Cyan  /* #303a46  Timestamp header backgrounds in History tab (NO IDEA) */
$navpage-nav-app-text: Black  /* #cfd4d8  Core content text color (Application title, History hover + 2nd line text + separator text, Connect "OPEN CONVERSATIONS" + "No results found" + message line text, Help bar title + hover text) */
$navpage-nav-app-text-hover: #ffffff  /* #ffffff  Core content text color hover (NO IDEA) */

 

 

I used one of the OOB Theme records (I forget which one it was) as a starting point and added my own comments within () to hopefully clarify what is affected by the property.  Some of the comments from the OOB Theme are incorrect now in Istanbul.  I've added a comment of "NO IDEA" to some of the properties because I do not know what they control now, and suspect they no longer affect anything.

 

Here are the property names, along with it's default value, used in the Theme record and screenshots of the controls/areas they affect.  I used yellow as the value for each property so the controls would stand out in the screenshots (sorry for the flash of yellow about half-way down the article ).

 

$navpage-header-bg - #303a46

  • Banner frame background

 

 

$navpage-header-color - #ffffff

  • Banner frame title text
  • Global Search, Application and Update Set icon outlines

 

 

$navpage-header-button-color (no default, not documented)

  • Logged-in user name text
  • Connect, Help and Settings icons

 

 

$navpage-header-divider-color - #455464

  • Banner frame separator line

 

 

$navpage-button-color - #ffffff

  • Buttons in the Navigator bar (when maximized)
  • Favorite items text
  • 1st line of History items
  • Connect message record display value text
  • Create a New Conversation, Open Connect standalone interface and Close Connect Sidebar icons

        

 

 

$navpage-button-color-hover - #7ec24F

  • Global Search, Connect, Help and Settings icons when cursor is over the control (only the Global Search icon is highlighted in the first screenshot below but the others will highlight when the cursor is over them)
  • Clear search text icon when cursor is over the control in Navigator and Connect sidebar
  • Navigator bar icon when clicked (some browsers [e.g. Chrome] only remove the highlight after cursor is clicked elsewhere)

   

 

 

$search-text-color - #e7e9eb

  • Global Search, Navigator and Connect search text
  • Clear search text icon in Navigator and Connect search boxes
  • Navigator bar icons when minimized

 

 

$navpage-nav-border - #dddddd

  • Global Search, Navigator and Connect search box outlines
  • Navigator and Connect search box filter icons
  • Outline of logged-in user control when selecting a drop-down menu item

 

 

 

$nav-highlight-main - #3D4853

  • Module/Favorite (not in Safari)/History/Help item when clicked (each browser has its own quirks with this one - Safari only shows while clicking the item, others will keep the highlight a second or so, and some keep the Help item highlighted until the cursor is clicked elsewhere)
  • Selected Connect item (remains highlighted until another is selected or another record's chat window is selected or the record's chat window is closed)
  • Vertical separator line between main frame and Navigator/Sidebars

    

  

 

 

$navpage-nav-bg - #303a46

  • Navigator, Connect and Help Sidebar header and footers
  • Unselected Navigator tabs background
  • Module background
  • History time separator background

 

 

$navpage-nav-bg-sub - #455464

  • Navigator, Connect and Help Sidebar backgrounds
  • Background for Apps/Favorites/History
  • Selected icon when editing a Favorite

 

 

$nav-hr-color - #303a46

  • Separator modules without a label

 

 

$nav-highlight-bar-active - #278efc

  • Highlight line under active Navigator tab (Apps, Favorites or History)
  • Selected Connect, Help or Settings icon (only the Connect icon is highlighted in the screenshot below but the others will highlight when clicked/selected)
  • Number of Connect messages dot
  • Outline of logged-in user control when selected

 

 

$nav-highlight-bar-inactive - #828890

  • Line under inactive Navigator tab

 

 

$navpage-nav-selected-bg - #4b545F

  • Background for currently selected Navigator tab (Apps, Favorites or History)

 

 

$navpage-nav-selected-color - #ffffff

  • Active Navigator tab icon (Apps, Favorites or History)

 

 

$navpage-nav-unselected-color - #bec1c6

  • Inactive Navigator tab icons (Apps, Favorites or History)
  • Module title text

 

 

$navpage-nav-app-text - #cfd4d8

  • Application title text and Application hover title text
  • Edit Application and Add to Favorites icons
  • History time separator text
  • History 2nd line text
  • History hover text
  • Connect message text
  • Connect "OPEN CONVERSATIONS" and other informational text
  • Help sidebar title and hover text

       

 

 

No Longer Used?

Here are some properties used in Helsinki that do not seem to be used in Istanbul anymore:

  • $subnav-background-color - #455464
  • $navpage-nav-color-sub - #bec1c6
  • $navpage-nav-mod-text-hover - #ffffff
  • $connect-latest-message - #cfd4d8
  • $nav-timeago-header-color - #303a46
  • $navpage-nav-app-text-hover - #ffffff

 

The default values listed are from Helsinki.

 

 

Unkown Properties

Here are a few controls or places in the UI that I do not know the name of the property that controls the color:

  • Search boxes placeholder text
  • Unselected Apps/Favs/History icon hover background
  • Last Application selected background
  • Application hover background
  • Module hover background
  • Icon hover backgrounds (Banner frame, Nav bar, Connect, etc...)

 

 

Setting a Default Theme for Users

The currently selected Theme for each user is saved in a User Preference called "glide.css.theme.ui16".  The value of the preference contains either "system" for the "System" Theme or the sys_id of one of the other Theme records.

 

You can set a default Theme for everyone by creating a new User Preference record with the "System" field checked and the "User" field left empty.  That will set the Theme for each user until they actually select a different one, which will then be saved in a User Preference record of their own.

 

Setting a default Theme does not, however, affect the look of the login page - it will use the properties of the "System" Theme - and that would look a little odd, the colors switching on the user as they login.

 

 

Overriding the "System" Theme

You may have noticed that all the Themes that are listed in the System Settings popup window have a corresponding Theme record (System UI \ Themes) except for the "System" one:

That's because the "System" Theme uses hard-coded values and System Properties to override them.  To override a "System" Theme color, you must create or edit one of the System Properties and not an actual Theme record.  The name of the System Property would be "css." + name of the css property from above (e.g. "css.$nav-highlight-bar-active")

 

 

What's Missing?

The most obvious omission with the Theme concept, I believe, is the ability to set a banner frame logo right in the Theme record because some themes may have a light background, requiring a dark logo, while others may have a dark background requiring a lighter logo.

 

I also believe some properties should not be shared.  For instance, the Global Search and Navigator search text colors should be controlled by different properties because the banner background may be a light color requiring a dark text color for the Global Search text box and the Navigator background may be darker, requiring a lighter color for it's search text.  Same thing for their control outlines.

 

 

Please Create a System Theme record

It would be a lot more useful if the "System" Theme was actually a record instead of all the System Properties.  Would make editing the default Theme a lot easier.

 

 

Resources

Here are a couple links to the Istanbul docs and other pages that may be useful:

 

 

Updates

I'll try to keep this post updated with anything new that I find.  Please let me know if I've missed anything.  Thanks in advance.

 

 

Updated Thursday, April 20, 2017

  • added "$navpage-header-button-color" property

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

This post was inspired by a question posted here - Dependent Choice List in Requested Items

 

The poster wanted to add 2 extra choices to the State field based on what Catalog Item was ordered. If a particular item was ordered, he wanted to add "On Hold" and "Awaiting User Info" as valid choices to the State field.  Of course the often used "g_form.addOption" and "g_form.removeOption" methods were suggested (guilty) as a means to solve the issue, but anything running client-side really runs the risk of causing issues.  One issue is the choice list would not be updated in list views.

 

So after some playing around, the solution can actually be handled with Dependent Values.  I spent a bit of time experimenting with it and came up with the following that works:

 

1. Add a new field called "State Set" on the Task table (you might want to use it elsewhere) with a default value of "default"

 

2. Add a Dictionary Override on the Task.State field for the Requested Item table with "Override dependent" selected and "u_state_set" in the "Dependent" field:

 

3. Add 2 new sets of choices for the sc_req_item.state field, one where the Dependent value field is "default" for your default set of choices and the other "hold" that includes the default values and the 2 new ones:

 

Be careful when adding new "Values" for the State field - use a unique and higher number for any custom choices you add, as shown above (I like to start at 100), and do NOT re-use any out-of-box values as they mean something to the OOB code base.

 

4. Build a Business Rule to populate the "State Set" field based on whatever criteria you need (e.g. set to "hold" when the "Item" field is the particular catalog item, etc...)

 

5. The proper set of choices will now display in the form and list views:

 

6. Add an Access Control rule on the State Set field that only allows users with the "admin" role to edit it.  There is an issue with this, however - the State field will not be editable either in a list view because it is dependent on the State Set field which is not editable.  I consider this to be a bug or at least an oversight.  I think it is an acceptable use case to restrict write access to the parent field in the dependency but allow the child to be edited.  The reverse is not, however.

 

So this allows you to create a number of choice list "sets" based on the State Set field without having to worry about adding or removing options through client scripts.  It means some extra choices to maintain, but usually you will not have to edit them very often, if ever, once configured.

 

This was tested in Istanbul.

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

Jim Coyne

"Developer Toolbox" Tool

Posted by Jim Coyne Nov 9, 2016

Not really a tool in itself, but a collection of modules with links to some tables and pages within the platform.  Some are not used very often, but are useful nonetheless.  Most of them are for tables that do not have an existing module and I can never remember the table name, or keep misspelling it 

 

I've attached an XML export of my current Update Set.  It contains records for:

  • the "Developer Toolbox" Application Menu, which is restricted to the "admin" role and normally is the first Application shown in the Navigator
  • the "Developer Toolbox" Menu Category which adds a red highlight to the Application menu (UI14 and below)
  • the "glide.ui14.navigator.use_border_color" System Property, set to "true", which shows the red highlight on the Application Menu (see Fuji screenshot below)
  • an Image, "u_CMDBHardwareHierarchy.gif", used to show a subset of the Hardware CMDB class hierarchy from the "Hardware Hierarchy Map" Module (I find it useful to show new clients how classes work)
  • numerous Modules (currently 46) with links to different tables and pages

 

The Modules are grouped into three different sections:

  • Useful Links
  • Useful Pages
  • Verify Post-Clone Tasks

 

Screenshot from Geneva:

 

Screenshot from Fuji:

 

 

Here's the CMDB hierarchy image:

u_CMDBHardwareHierarchy.gif

 

It helps when explaining the class/subclass inheritance model to clients.

 

I usually install the Update Set in every instance that I work in, hoping to add a little bit of productivity to my day.  The Post-Clone section is handy for verifying common things after you perform a clone.  I keep adding new modules as I come across new tables, pages or tasks that I need to perform.

 

Please share any links you may have created in the past or might be inspired to add in the future.

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

In a related article, "Related Attachments" Related List, I talk about creating a Defined Related List to pull together attachments from related records so they can show up on the form view of all those records (e.g. Service Desk Calls and Incidents):

 

 

It's nice to have them all in one place, but the "Table name" and "Table sys ID" fields are not very useful.  Luckily we can improve on that.

 

We simply need to create a new calculated field called "Record" of type "Document ID" on the Attachment table.  To do this, enter "sys_attachment.list" in the Navigator filter - this will display a list of attachment records.  Then right-click on the list header and select Configure \ Dictionary.  Create a new record with the following settings (you may have to click on the Advanced View Related Link to show some of these fields):

 

Table:                   Attachment [sys_attachment]

Type:                    Document ID

Column label:            Record (or whatever else you prefer)

Use dependent field:     checked

Dependent on field:      Table name

Calculated:              checked

Calculation:

(function calculatedFieldValue(current) {
  return current.getValue("table_sys_id");
})(current);

 

I normally steer everyone away from Calculated fields because they can be expensive in terms of database cycles, however, I am told that creating a calculated field from values that are available on the same record is indeed safe.

 

Now we can have a useful Related List on the appropriate forms by replacing the fields that are displayed (right-click Configure \ List Layout) by removing the "Table name" and "Table sys ID" fields and adding the new "Record" field:

 

 

Now you can see the record the attachment is actually on, and even click on the link to go to that particular record.

 

 

 

NOTE: My earlier blog post, A Better Requested Item Attachments Related List, got a little messy so I split it into 2 different posts so it would be easier to read and update.  This post is the second of those 2 new posts.

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

I've seen a lot of requests in the Community to see related attachments on multiple forms.  For instance, people want to see Requested Item attachments on the related Catalog Task records as well.  Most "solutions" that are suggested involve copying the attachments from one record to the other, which you really do not want to do (synching problems, duplicate records for no reason, etc...).  My solution is to create a Defined Related List (Creating Defined Related Lists - ServiceNow Wiki) which can display attachments from multiple records.

 

We start by adding a new Relationship record (System Definition \ Relationships):

 

Name:                 Related Attachments

Applies to table:     Global [global]

Queries from table:   Attachment [sys_attachment]

Query with:

 

(function refineQuery(current, parent) {
  var tableName = parent.getTableName();
  var queryString = "table_name=" + tableName + " ^table_sys_id=" + parent.getValue("sys_id");  //default query

  switch (tableName){
    //add your table-specific blocks from below
  }

  current.addEncodedQuery(queryString);


  function u_getRelatedRecords(table, field, sysId){
    var result = "";
    var gr = new GlideRecord(table);
    gr.addQuery(field, sysId);
    gr.query();
    while (gr.next()){
      result += "," + gr.getValue("sys_id");
    }
    return result;
  }

})(current, parent);

 

The script checks the table name for the record being displayed and then builds the appropriate query.  As a safety measure, the queryString variable is given a default query to display the attachments for just that one record, otherwise all attachments would appear in the list if the Related List was added to a form that did not have any specific "case" block.  I created the private "u_getRelatedRecords" function to simplify the whole script as we use the same GlideRecord query to retrieve the appropriate sys_ids regardless of the table.

 

The above script is just the starting block - we'll add table specific examples next.  Each of the next blocks of code should be inserted within the "switch" block at line 6:

 

Request, Requested Item and Catalog Task Tables

 

    //===== Requests =====
    case "sc_request":
    queryString = "table_nameINsc_request,sc_req_item,sc_task^table_sys_idIN" + parent.getValue("sys_id");

    //find the related Requested Items
    queryString += u_getRelatedRecords("sc_req_item", "request", parent.getValue("sys_id"));

    //and then the Catalog Tasks
    queryString += u_getRelatedRecords("sc_task", "request_item.request", parent.getValue("sys_id"));
    break;


    //===== Requested Items =====
    case "sc_req_item":
    queryString = "table_nameINsc_request,sc_req_item,sc_task^table_sys_idIN" + parent.getValue("request") + "," + parent.getValue("sys_id"); 

    //find the related Catalog Tasks 
    queryString += u_getRelatedRecords("sc_task", "request_item", parent.getValue("sys_id"));
    break;


    //===== Catalog Tasks =====
    case "sc_task":
    queryString = "table_nameINsc_request,sc_req_item,sc_task^table_sys_idIN" + parent.request_item.request.toString() + "," + parent.getValue("request_item");

    //find the related Catalog Tasks
    queryString += u_getRelatedRecords("sc_task", "request_item", parent.getValue("request_item"));
    break;

 

 

 

Incident and Service Desk Call Tables

 

    //===== Incidents =====
    case "incident":
    queryString = "table_nameINincident,new_call^table_sys_idIN" + parent.getValue("sys_id");

    //find the related New Call
    queryString += u_getRelatedRecords("new_call", "transferred_to", parent.getValue("sys_id"));
    break;


    //===== Service Desk Calls =====
    case "new_call":
    queryString = "table_nameINincident,new_call^table_sys_idIN" + parent.getValue("sys_id") + "," + parent.getValue("transferred_to");
    break;

 

 

 

Idea and Demand Tables

 

    //===== Idea =====
    case "idea":
    queryString = "table_nameINidea,dmn_demand^table_sys_idIN" + parent.getValue("sys_id") + "," + parent.getValue("demand");
    break;


    //===== Demand =====
    case "dmn_demand":
    queryString = "table_nameINidea,dmn_demand^table_sys_idIN" + parent.getValue("sys_id") + "," + parent.getValue("idea");
    break;

 

 

 

Project and Project Task Tables

 

  //===== Project =====
  case "pm_project":
  queryString = "table_nameINpm_project,pm_project_task,idea,dmn_demand^table_sys_idIN" + parent.getValue("sys_id");

  //find the related Project Tasks
  queryString += u_getRelatedRecords("pm_project_task", "top_task", parent.getValue("top_task"));

  //find the related Idea and Demand
  queryString += u_getRelatedRecords("dmn_demand", "project", parent.getValue("sys_id"));
  queryString += u_getRelatedRecords("idea", "demand.project", parent.getValue("sys_id"));
  break;


  //===== Project Task =====
  case "pm_project_task":
  queryString = "table_nameINpm_project,pm_project_task,idea,dmn_demand^table_sys_idIN" + parent.getValue("top_task");

  //find the related Project Tasks
  queryString += u_getRelatedRecords("pm_project_task", "top_task", parent.getValue("top_task"));

  //find the related Idea and Demand
  queryString += u_getRelatedRecords("dmn_demand", "project", parent.getValue("top_task"));
  queryString += u_getRelatedRecords("idea", "demand.project", parent.getValue("top_task"));
  break;

 

 

 

HR Case and HR Task Tables

 

    //===== HR Case =====
    case "hr_case":
    queryString = "table_nameINhr_case,hr_task^table_sys_idIN" + parent.getValue("sys_id");

    //find the related HR Tasks
    queryString += u_getRelatedRecords("hr_task", "parent", parent.getValue("sys_id"));
    break;


    //===== HR Tasks =====
    case "hr_task":
    queryString = "table_nameINhr_case,hr_task^table_sys_idIN" + parent.getValue("sys_id") + "," + parent.getValue("parent");

 

 

 

Now you can see all the attachments from related records if you add the "Related Attachments" Related List to a form:

 

The above blocks of code are just examples of what you can do and there are quite a few more that can be added.  I'll add some more as I come across some more ideas or people ask for more.

 

 

If you want a better looking and more useful list view, you will want to read this post - Improving the Attachments List View:

You will be able to see the record the attachment is actually on (instead of a sys_id), and even click on the link to go to that particular record.

 

 

NOTE: My earlier blog post, A Better Requested Item Attachments Related List, got a little messy so I split it into 2 different posts so it would be easier to read and update if required.  This post is the first of those 2 new posts.

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

Building on the "Xplore GlideRecord Script" Tool post, the "Preview in Background Script" tool will open a new Background Script window and populate the script field with the template of code containing the list view's query:

 

 

The script will be populated 1/4 second after the Background Script window is opened in order to ensure the window has been opened properly.

 

All you need to do is create a new Context Menu record with the following details:

 

Table: Global

Menu: List Header

Type: Action

Name: Preview in Background Script

Order: 116,000

Condition: gs.hasRole("admin")

Action script:

 

(function u_previewGlideRecordScript(){
  var fixedQuery = ("" + g_list.getFixedQuery()).replace("null", "");
  if (fixedQuery == "") {
  fixedQuery = ("" + g_list.getRelatedQuery()).replace("null", "");
  }
  var query = fixedQuery;
  var listQuery = g_list.getQuery();
  if (listQuery != "") {
  if (query == "") {
  query = listQuery;
  } else {
  query += "^" + listQuery;
  }
  }
  var newLine = "\n";
  var script = "(function() {" + newLine;
  script += "    var gr = new GlideRecord('" + g_list.tableName + "');" + newLine;
  if (query != "") {
  script += "    gr.addEncodedQuery('" + query + "');" + newLine;
  }
  script += "    //gr.setLimit(100);" + newLine;
  script += "    //gr.setWorkflow(false);" + newLine;
  script += "    //gr.autoSysFields(false);" + newLine;
  script += "    gr.query();" + newLine;
  script += "    while (gr.next()) {" + newLine;
  script += "        " + newLine;
  script += "    }" + newLine;
  script += "})();";

  // open the Background Scripts page in a new window
  var win = window.open('/sys.scripts.do');

  //and then populate the script box a quarter second later
  setTimeout(function(){
  try{
  var textArea = win.document.getElementById("runscript");
  textArea.value = script;
  } catch(err){}
  }, 250);
})();

 

 

Related posts:

"Preview GlideRecord Script" Tool

"Xplore GlideRecord Script" Tool

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

I previously wrote a helpful little tool called "Preview GlideRecord Script" which would popup a window with the current list view's filter within a block of code:

This would allow you to copy and paste the code wherever you needed it and use it as a starting point.  I thought I'd do the same thing for James.Neale's excellent Xplore tool.  All you need to do is create a new Context Menu record with the following details:

 

Table: Global

Menu: List Header

Type: Action

Name: Xplore GlideRecord Script

Order: 116,000

Condition: gs.hasRole("admin")

Action script:

(function u_previewGlideRecordScript(){
  var fixedQuery = ("" + g_list.getFixedQuery()).replace("null", "");
  if (fixedQuery == "") {
  fixedQuery = ("" + g_list.getRelatedQuery()).replace("null", "");
  }
  var query = fixedQuery;
  var listQuery = g_list.getQuery();
  if (listQuery != "") {
  if (query == "") {
  query = listQuery;
  } else {
  query += "^" + listQuery;
  }
  }
  var newLine = "\n";
  var script = "(function() {" + newLine;
  script += "    var gr = new GlideRecord('" + g_list.tableName + "');" + newLine;
  if (query != "") {
  script += "    gr.addEncodedQuery('" + query + "');" + newLine;
  }
  script += "    //gr.setLimit(100);" + newLine;
  script += "    //gr.setWorkflow(false);" + newLine;
  script += "    //gr.autoSysFields(false);" + newLine;
  script += "    gr.query();" + newLine;
  script += "    while (gr.next()) {" + newLine;
  script += "        " + newLine;
  script += "    }" + newLine;
  script += "})();";

  //open the Xplore tool in a new window
  var win = window.open('/snd_xplore.do');

  //when Xplore has loaded, set the script
  jQuery(win).bind('load', function(){
    win.snd_xplore_editor.setValue(script);
  });
})();

 

This now adds a new context menu when you right-click a list view header:

 

When you select it, a new Xplore window is opened and populated with the block of code containing the list view's query:

 

You obviously need to install the Xplore tool itself in order for this to work and it can be found on the Share site - https://share.servicenow.com/app.do#/detailV2/bbe5dd7213e7de004e8cd4a76144b0ef/overview

 

Have a good weekend!

 

Related posts:

"Preview GlideRecord Script" Tool

"Preview in Background Script" Tool

*** Please Like and/or tag responses as being Correct.
And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***

Filter Blog

By date: By tag: