logo

NJP

Get Form table name and descendants without going to table definition

Import · Aug 07, 2019 · article

I enjoy using this, that's why I wanted to share it. You ServiceNow Developers might find it useful.

In order to get the table details and descendants for underlying form, I have to go to Configure and then Table as bellow.

image

However, I just get to the table name for this form for descendant tables I have to go all the way.

This process is a bit cumbersome.

I have developed a basic thing to get the table name and descendants using the global UI Action for the underlying form as follows.

In this sample, I used the CMDB Linux Server.

image

The result:

image

When clicking on the table names, it navigates to table description.

Here are the development details.

  1. Create two Script Include files

TableUtilsCustom.js Runs on the server

TableUtilsCustomAjax.js Client callable

  1. Create a global UI Action.

image

Script:

function getTableName() {

try {

var table_name = g_form.getTableName();

copyToClipboard(table_name);

var gra = new GlideAjax("TableUtilsCustomAjax");

gra.addParam("sysparm_name", "getHierarchy");

gra.addParam("sysparm_table_name", table_name);

gra.getXMLWait();

var result = gra.getAnswer();

var gdw = new GlideModal("glide_warn", false, 400);

gdw.setTitle(getMessage('About table'));

gdw.setPreference('title', result);

gdw.render();

} catch (ex) {

g_form.addErrorMessage(ex);

}

}

Include files are attached.

Feel free to ask any question.

Hope you enjoy it.

Regards,

Yusuf

View original source

https://www.servicenow.com/community/developer-articles/get-form-table-name-and-descendants-without-going-to-table/ta-p/2295363