What is the use of initialize :function(){} in Script include and How to write private function in Script Include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2020 01:05 AM
What is the use of initialize : function(){} in Script include and How to write the private function in Script Include?
What is the difference between Client callable and Server Side calling in Script include, If we check Client callable any difference is there in script include.
Thanks
Ram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2020 02:56 AM
initialize function is something which holds the code that is made available to all the other functions defined over that script include.
private functions are something which are called in same scope of script include and not from outside
Refer below links for more help
Scripting 101: Script Includes - Class vs Classless
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2020 04:22 AM
Let me know if that answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2020 04:33 AM
Explanation on initialize is provide in the following thread:
"Client callable" in Script Include makes the script available to client:
Makes the script include available to client scripts, list/report filters, reference qualifiers, or if specified as part of the URL.
Also check difference between getXML() and getXMLAnswer() methods.
Difference in coding between Client Callable and Script Include. Script Include is now often recommended.
https://earlduque.com/2019/07/31/Client-Callable-and-Server-Callable-Script-Includes.html
Information on privacy of client-callable script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2020 01:54 AM
Hi Ram,
When we are writing code only for server side means client checkbox is not checked then we have a initialize function available in script include Class code.
This initialize function is actually very useful. Whatever code we write in initialize () function then it will get execute every time when we create an object of script include class.
The initialize() function is basically the constructor for the initialized object.
var objDemo=new DemoScriptIncludeClass();
once we have initialized object objDemo of class DemoScriptIncludeClass as mentioned above then the code written in initialize () will get executed.
I hope this helps to understand the concept.
Private function:
Private function in script include is basically which is not accessible from client side. Private functions should have prefix “ _”. Below is the screenshot for the same:
![]() |
To use script include servicenow at client side we have to make sure that client callable checkbox in script include interface should be checked and script include class should be extending class ‘AbstractAjaxProcessor’ (glide ajax – through which client script communicate with server-side script).
If my answer helped you in any way, mark answer as helpful and correct.
Thanks and regards,
Megha.