logo

NJP

[SwissNow] How to find specific sys_id in the system

Import · Jul 16, 2019 · article

image

2. Record with specific sys_id will be open

image

How to configure:

1. Install SwissNow: https://chrome.google.com/webstore/detail/swissnow-servicenow-toolb/jneeammdkdmlfgidcacmjmbijdmkdbjm

2. Click SwissNow/Custom Scripts

3. Click New script

image

4. Provide script name and required parameters (in this case - "sys_id"). Then click "Add" to add the parameter.

image

5. Paste following script:

var tables = new GlideRecord('sys_db_object');
tables.addEncodedQuery('super_classISEMPTY^nameNOT LIKEts_c_^nameNOT LIKEsysx_^nameNOT LIKEv_');
tables.query();
while (tables._next()) {
    var tableName = tables.getValue('name');
    var column = new GlideRecord('sys_dictionary');
    column.addEncodedQuery('name=' + tableName + '^element=sys_id');
    column.queryNoDomain();
    if (!column.next())
        continue;

    var gr = new GlideRecord(tableName);
    gr.addQuery('sys_id', sys_id);
    gr.queryNoDomain();

    if (gr._next()) {
        gs.info('!url=' + gr.getLink());
        break;
    }
}

Note: the script will output "!url=https://this.is.your.url/" to automatically redirect user to specific URL after the script has been executed.

6. Click "Save"

View original source

https://www.servicenow.com/community/developer-articles/swissnow-how-to-find-specific-sys-id-in-the-system/ta-p/2328066