THURSDAY, JANUARY 19, 2017

Show a Table Schema Map from any Form

T

able schema maps are a very useful tool to aid in visualizing the setup of a table and its relationships to other tables and fields in ServiceNow. This functionality is something that every ServiceNow implementor or admin should be familiar with. Schema maps are documented here in the ServiceNow wiki.

While the schema map is useful, it can also be difficult to navigate to unless you know exactly where to look. The only place in the system to access the schema map is from the ‘Tables and Columns’ module and this is only available to users with the admin role. In this post I’ll show you how you can make the schema map for a given table more accessible by creating a global UI action link that allows you to display the table schema map from any form in the system – for any role you want.

Show Schema Map

Here’s the UI action code. Notice that it’s set on the ‘Global’ table so that it will be available as a link on every form in the system. You’ll also notice that the ‘Condition’ field is set to allow access to only the admin role. You can adjust this as needed to grant access to other users as well. I’ve also added a couple of checks in the script to see if the action is initiated from the dictionary or the label table. In these cases, the popup will pull from the table defined in the dictionary or label entry – rather than the actual ‘sys_dictionary’ or ‘sys_documentation’ tables.

‘Show Schema Map’ UI Action
Name: Show Schema Map
Table: Global
Action name: show_schema_map
Form link: True
Client: True
Onclick: showSchemaMap()
Condition: gs.hasRole(‘admin’)
Script:

function showSchemaMap(){
   //Get the table name
   var tableName = g_form.tableName;
   if(tableName == 'sys_dictionary' || tableName == 'sys_documentation'){
      //Use 'Table' field value for dictionary or labels
      tableName = g_form.getValue('name');
   }
   getTopWindow().popupOpenFocus('schema_map2.do?sysparm_stack=no&sysparm_attributes=table=' + tableName, 'super_schema', 950, 700, '', false, false);
}

5 Comments

Josh 10-02-2012, 11:17

Where I found this very useful is when review CI’s and trying to see the relationships. This is very nice for that area. thanks!

Reply
Ravish 16-02-2012, 22:13

nice

Reply
Lakshmi Roy 02-11-2012, 05:05

I tried “Show a Table Schema Map from any Form”
procedure, but its not working. Kindly suggest some other way.

Reply
Mark Stanger 02-11-2012, 05:53

I just tested it on a ServiceNow demo instance and it works fine. This is the only way I know of, so just follow the instructions here.

Reply
Jim Coyne 13-12-2012, 22:26

I really like this function and use it all the time. I just posted an article on how to do the same thing from a List view as well – http://community.servicenow.com/blog/jimcoyne/showing-schema-map-list-view

Reply

Leave a Reply


Latest Comments

  • David: It appears that I can hit sys_properties table with REST. This works, but I haven’t yet discovered the...
  • Mark Stanger: Hey David, It doesn’t surprise me that scoped apps have made this more difficult. I’m not...
  • David: Mark, do you have an example of how to do this in a scoped app? It seems there are many hoops to jump through...
  • Mark Stanger: The only possibility is to create a system property to override this in your application. Check out the...