The CreatorCon Call for Content is officially open! Get started here.

Find the usage of script include

Khanna Ji
Tera Guru

I would like to know how to find scripts which call a script include. It could be a CS, BR, Workflow, Flow etc. 

I have been asked to modify the script include but also requested me to share the impact and usage of the script across the platform. This is a custom script include developed by somebody else few years back.

I am sure you might have come across this situation. Please help.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@ServiceNow User 

I could think of these

here are the common Scripts

https://docs.servicenow.com/bundle/paris-application-development/page/script/general-scripting/refer...

1) Client Side

    Client Scripts
    UI Policy
    UI Scripts
    Catalog Client Script
    Catalog UI Policy
    Widget client script
    UI Pages - Client script

2) Server Side

    Business rule
    Script include
    Script action
    Schedule job
    Fix Scripts
    Workflow run script
    Email Scripts
    Installation Exits
    Widget server side script
    ACL Script
    Transform map scripts
    Field map scripts
    UI Actions
    UI Pages - Processing script
    UI Macros

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

17 REPLIES 17

In fact you are diverting the question. If you see my first post, I mentioned I want to know the usage of script include. So workflow and it's activities is also needed for answering this question.

Since the question is about finding reference to script include in scripts, add also wf_activity table to the list.

EDIT: As I've mentioned before, try adding all the tables listed in sys_documentation table to find all occurrences in ServiceNow.

As requested.

The script searches for a string so for example in the following Run Workflow script, I'll search for string 'Item Designer - generate approvals for current sequence' used in scripts. 

find_real_file.png

Script

var searchString = 'Item Designer - generate approvals for current sequence';

var tableList = ['sys_script_client','sys_ui_policy','sys_ui_script','catalog_ui_policy','sys_widgets','sys_ui_page',
'sys_script','sys_script_include','sysevent_script_action','sysauto','sys_script_fix',
'sys_script_email','sys_installation_exit','sp_widget','sys_security_acl','sys_transform_script',
'sys_transform_entry','sys_ui_action','sys_ui_page','sys_ui_macro','sys_ws_definition','sys_script_validator',
'sys_variable_value'];

tableList.forEach(searchText);


function searchText(tableName) {
  gs.info(tableName + '*************************');
  var gr = new GlideRecord(tableName);
  if (tableName != 'sys_variable_value') {
    gr.addQuery('IR_AND_OR_QUERY', searchString);
    gr.query();
    while (gr.next()) {
      gs.info('####:' + tableName + ':' + gr.name);
    }
  } else {
    gr.addEncodedQuery('valueLIKE' + searchString);
    gr.query();
    while (gr.next()) {
      gs.info('####:' + tableName + ':' + gr.document + ",id:" + gr.document_key + ",value:" + gr.value);
    }
  }
}

Screenshot of background script that I ran

find_real_file.png

Execution output:

find_real_file.png

MrMuhammad
Giga Sage

Hi - Did you tried code search in studio? You can search by script include name and It will give you all the occurences of script include.

https://community.servicenow.com/community?id=community_blog&sys_id=136caea1dbd0dbc01dcaf3231f96198a

Regards,
Muhammad

Code search only searches these tables:

  • Access Control
  • Business Rule
  • Client Script
  • Email Template
  • Inbound Email Action
  • Map Page
  • Notification
  • Processor
  • Relationship
  • Scheduled Script Execution
  • Script Action
  • Script Include
  • Style
  • Table Transform Map
  • UI Action
  • UI Macro
  • UI Page
  • UI Policy
  • UI Script