Server side script

ArpitG
Tera Contributor

Hello Team,

I am new in service now and willing to learn the java script. When I tried to run the script on server side I am getting the following message which you can see in the attached screenshot. Please check and suggest what needs to be done from my side and how can I learn javascript at fast paceJS error.png

5 REPLIES 5

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @ArpitG 

 

It means your script has been executed and you can see the results - click on available here.

 

Learn more about scripting

https://www.youtube.com/playlist?list=PLi0Ik1xCDEbK5BJme5YSGZASvl0nkaFHn

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

PrashantLearnIT
Giga Sage

Hi @ArpitG 

 

You have executed your scripts successfully, You can learn Scripts in following playlists - https://youtube.com/playlist?list=PLmMLNh-9xqQEcCUSv00ZpUF328zTYPgoK&si=vvWPAo2GRA00qOJ5

 

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

Hitoshi Ozawa
Giga Sage
Giga Sage

Seems like you've executed a script in Scripts - Background.

If the script doesn't change and record nor have an output, that's what you'll see.

If you want to see some output, try using gs.info() method.

Example:

 

var a = 1;
gs.info("value of variable a:" + a);

 

execution result:

 

[0:00:00.040] Script completed in scope global: script
Script execution history and recovery available here
*** Script: value of variable a:1

 

 

If a record is updated, it will show number of record that was updated.

Example:

 

var user_name = 'abel.tuter';

var gr = new GlideRecord('sys_user');
gr.addQuery('user_name', user_name);
gr.query();
if (gr.next()) {
	gr.setValue('active', false);
	gr.update();
	gs.print("User " + user_name + " has been disabled.");
}

 

execution result:

 

[0:00:00.453] Script completed in scope global: script
Script execution history and recovery available here
Operation	Table	Row Count
update	sys_user	1
[CacheFlushLog] event=sys_user, count=1, ms=0: Flushing catalog sys_user
[CacheFlushLog] event=user_criteria_cache, count=1, ms=31: Flushing catalog user_criteria_cache
[CacheFlushLog] event=knowledge_base_cache, count=1, ms=1: Flushing catalog knowledge_base_cache
[CacheFlushLog] event=USER_ITEMS_CACHE, count=1, ms=2: Flushing catalog USER_ITEMS_CACHE
[CacheFlushLog] event=USER_CATEGORIES_CACHE, count=1, ms=1: Flushing catalog USER_CATEGORIES_CACHE
*** Script: ExternalAuth: provider_user_map is de-activated for user:62826bf03710200044e0bfc8bcbe5df1
*** Script: User abel.tuter has been disabled.

 

 

Anand Kumar P
Giga Patron

Hi @ArpitG ,

 

You can prevent this by using getValue('fieldname') or getDisplayValue('fieldname') 

var field = get.fieldname;//use below one instead of this sometimes it will return empty results.

var variable = get.getValue('fieldname'); 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand