- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2020 06:44 AM
If I have script include MyClass wich clicent callable with method myFunction and if I pass 'sysparm_number' and 'sysparm_user', what is the code that I can put in background script to test? Appreciate it.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2020 06:49 AM
Hi,
you need to check the value of the parameter
you can make the function as both client callable with sysparm_number or passing the function parameter
getIncidents: function(number1){
var number = JSUtil.nil(number1) ? this.getParameter('sysparm_number') : number1;
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
ā10-08-2020 06:49 AM
Hi,
you need to check the value of the parameter
you can make the function as both client callable with sysparm_number or passing the function parameter
getIncidents: function(number1){
var number = JSUtil.nil(number1) ? this.getParameter('sysparm_number') : number1;
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
ā10-08-2020 07:58 AM
Hi,
you can call your SI from bg like this
new MyClass().myFunction("1234","user");
and in your SI, you can use the code provided by Ankur and test it.
Let me know if you need any further assistance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2020 08:18 AM
Thanks. Will test it. It would help without modifying existing scripts as they don't have parameters declared in the function definition and code to assign properly.
But I really liked to have an option to test using snippet as mentioned by Ankur.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-08-2020 08:32 AM
Hi Giri,
if you want to use same function to be called from client side using GlideAjax and also from server side then that approach is better instead of creating duplicate functions for same functionality.
Let me know if I have 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