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

Hitoshi Ozawa
Giga Sage
Giga Sage

Following script will find occurrences of the string in tables.

var searchString = '<string to search>';  // class or method name

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'];

tableList.forEach(searchText);


function searchText(tableName) {
  gs.info(tableName + '*************************');
  var gr = new GlideRecord(tableName);
  gr.addQuery('IR_AND_OR_QUERY', searchString);
  gr.query();
  while (gr.next()) {
    gs.info(tableName + ':' + gr.name);
  }
}

What about Run Script in a workflow or Script section of a approval activities?

To find all tables in ServiceNow that has field named "script", search sys_documentation table. Add the table that need to be searched in the array.

For example, Workflow Activity Definition table (wf_activity_definition) 

 

Run Script data will be stored in Workflow activity definition, right? Can you share the screenshot for any script include? Also I have to run it as a background script, right?

Sorry, I'm actually not using workflow so that's why it wasn't included in my script. It's probably better to create a new question to find tables name to get other people to reply and also because it's diverting from the original question.

 

If using Studio, it's also possible to save resource to github and use grep to search. I think this is the best way to manage code and version. Unfortunately can't do this with existing resources and not applicable to the current question.