Debug Client Scripts

Viknesh Pannirs
Tera Expert

Is there a way to locate the name of the client script that is responsible for a specific action such as a field value got set?

I observed that if we write to jslog() then the log message only, without the script name, appears on the JavaScript log page.

However, consider a scenario where we don’t know the client script name but some error occurred due to a specific field update. In this case, normally we need to know the name of the client script responsible for the update action along with the time of update in the log.

 

I found the below line from the documentation however I don't get the steps to perform them.

"Additionally, when client scripts run, the name of the client script and timing information is displayed. This can be useful in determining which scripts are running and whether they are impacting performance."

https://docs.servicenow.com/bundle/sandiego-application-development/page/script/debugging/concept/c_WritingToTheDebugLog.html

3 REPLIES 3

Valmik Patil1
Kilo Sage

Hi ,

You can use field watcher to check what client scripts are running on that particular field

Field watcher will give the name of client script

Please refer below thread on how to enable field watcher

https://developer.servicenow.com/dev.do#!/learn/learning-plans/quebec/new_to_servicenow/app_store_le...

Thanks,

Valmik

 

Aman Kumar S
Kilo Patron

To navigate and point to client script that might be changing the form values, you can enable Field watcher.

You can open your form, and right click on the field label, click on "Show <field name>" context menu and the console should open to show the logs of changes.

Make sure, you have left navigation available on the form when you want to utilize field watcher

Best Regards
Aman Kumar

Viknesh Pannirs
Tera Expert

Thanks for the response. However, I have given an example with the field update but that helped me to know that there is a way to get the client script name.

But the intent of the question is to know where can I find the client script name that is responsible for specific behavior such as performance-related issues as well. What about on-load client scripts? 

An example is how to get the client script name that is the reason for slowness during on-load, submission, or modification of a form.