How to view functions referenced in Client script

AnthonyMull
Tera Contributor

Hi community,

 

I am working on our service now instance and trying to debug a client script. However in the client script there is a function being used that is defined somewhere else.

 

How can I find this function so I can understand what it is doing. Below is an example of what I am trying to find with dummy names used.

 

//At the bottom of client script I have.

valiadteMyFormFields('field_01','field_02',errMsg);

 

//I want to see the code for the function named validateMyFormFields, but I dont know where to find it.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @AnthonyMull ,

We can find a fuction name of client script in studio search.

polnilesh99_0-1735298358888.png

please explore below link for verification:

https://www.servicenow.com/community/developer-forum/searching-for-scripts-containing-certain-string...

View solution in original post

8 REPLIES 8

Vinod21
Tera Contributor

Hi 
Could you help me with the screenshot of your client script.

sanketpatil09
Tera Guru

To find this function, start by checking Script Includes under System Definition, as functions are often defined there for reuse. If it's a client-side script, look under System UI > UI Scripts, which houses global JavaScript files. You can also use the Global Text Search in ServiceNow to search for the function name across all scripts.

If these don't help, open the browser's developer tools (F12) while on the form and type console.log(validateMyFormFields) in the console to see where it's defined or its content. Additionally, review Client Scripts under System Definition to check if the function is defined in another related script.

 

These methods should help locate the function.

Community Alums
Not applicable

Hi @AnthonyMull ,

We can find a fuction name of client script in studio search.

polnilesh99_0-1735298358888.png

please explore below link for verification:

https://www.servicenow.com/community/developer-forum/searching-for-scripts-containing-certain-string...

Ankur Bawiskar
Tera Patron
Tera Patron

@AnthonyMull 

It could be present within a UI script.

Did you search there?

AnkurBawiskar_0-1735299866167.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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