GlideAjax: Not able to access function inside script include

jivanjotkaur
ServiceNow Employee
ServiceNow Employee

I have created a custom application and i am trying to do a GlideAjax, though onSubmit client script , to access a script include within the same scope. I put a debug statement each inside the 'initialize' and 'testfunction' which i am calling in my client script. I found that on execution of the script only the debug statement inside initialize is reflecting in the System Logs. Is the 'testfunction' not getting called at all? The value in the 'answer' variable is also null after execution.

Following is my script include:

Screen Shot 2015-10-04 at 1.40.53 AM.JPG

Corresponding Client Script:

Screen Shot 2015-10-04 at 1.41.32 AM.JPG

20 REPLIES 20

coryseering
ServiceNow Employee
ServiceNow Employee

Hi Jivonjot,



Don't prefix your script name with your scope- it's not needed if the Client Script and the Script Include being called are in the same scope.



Also, don't call setScope in your GlideAjax object. You never need to do that either.



Fix those 2 things, and I think you'll be good to go.


Hi Cory,



I had initially tried without setting the scope at those 2 places, but it did not work, so i added them as a just-in-case measure. The porblem seems to be that the testfunction is not getting called at all (the 2nd log statement is not getting executed) regardless of the scope setting.



I feel its a very trivial thing i am missing here, but i just can't seem to pin point it.


Hi Jivanjot,



Other than the scope stuff I mentioned before, I see nothing wrong with your Script Include nor your Client Sctipr.



Check your error log and the filesystem log when you make the request. Do you see any errors reported?



Viewing System Logs - ServiceNow Wiki



3.5 System Logs

System logs display warnings and errors within ServiceNow processes and records, and non-critical events such as memory usage on the ServiceNow server machine. This list view displays the log entries for the current day only. To view other log files, use the log file browser.


This log provides the following information for all occurrences:


FieldDescription
CreatedDate and time of the logging activity for the locale of the machine running the ServiceNow instance.
LevelType of message displayed. The levels are Debug, Error, Warning, and Information. A warning is an error that has been handled and recovered. An error is something that must be fixed.
MessageSystem-generated message regarding the nature of the occurrence.
SourceName of the process or area affected by the occurrence. For example, the source of the occurrence might be EMAIL or Memory.

3.6 Logging Utilities

ServiceNow provides the following logging utilities:


  • Log file browser
  • Log file download

3.6.1 Log File Browser

Use System Logs > Log File Browser to view any system log entry. You can search for log files by using the following filters:


FieldDescription
Start timeStart date and time of the range you want to search, for the locale of the machine running the ServiceNow instance
Session IDSystem-generated hexadecimal string that identifies the session that generated the log entry.
End timeEnd date and time of the range you want to search, for the locale of the machine running the ServiceNow instance
MessageSystem-generated description of the occurrence.
LevelType of message displayed. The levels are Debug, Error, Warning, and Information. A warning is an error that has been handled and recovered. An error is something that must be fixed.
Thread nameSystem-generated identifier of the thread that created the log file.
Max rowsMaximum number of records returned for a particular filter.

No Cory, there are no errors. Pradeep's setup seems to be working, i am wondering whether it is an issue with onSubmit.