Business Rule with gs.info

Ben Wang1
Kilo Contributor

In business rule I write script. where can show the message with "gs.info"?

if(current.name){
    gs.info('Name: '+ gs.getUser().getName());
}
1 ACCEPTED SOLUTION

Gaurav Shirsat
Mega Sage

Hello Ben

Is the script include in a scoped application If it is, then gs.log does not work and you should be using gs.info or gs.debug instead.

 You can send messages to customers as alerts, informative messages, or error messages.

1)current.field_name.setError("Hello World"); :-Will put "Hello World" below the specified field.

2)gs.addInfoMessage("Hello World"); :- Will put "Hello World" on the top of the screen.

3)gs.print("Hello World"); :-Will write to the text log on the file system but not to the sys_log table in the database.

4)gs.log("Hello World"); :-Will write to the Database and the log file.

https://docs.servicenow.com/bundle/orlando-application-development/page/script/general-scripting/ref...

What is System Log:-The System Logs module provides a variety of logs that you can use to troubleshoot and debug transactions and events that take place within the instance.

 https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/system-logs/conce...

 Please Follow The Steps:-
Application Navigator>System Logs>All...if filter Appears Remove it or check as per your requirement.
 
find_real_file.png
 

Please Mark Correct and Helpful

Thanks and Regards

Gaurav Shirsat

View solution in original post

4 REPLIES 4

Chander Bhusha1
Tera Guru

Hi Beng,

It will show in the system logs - All.

You need more specific the you add the filter as level is information

and search with message contains Name

 

find_real_file.png

 

Mark helpful and correct if it helps

thanks,

CB

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

gs.info() statements are shown in system logs

Easy way to find that Script log statements in left nav

find_real_file.png

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Jaspal Singh
Mega Patron
Mega Patron

Hi Ben,

 

As comments are already stating where it can be located just to get you understand the different it is as below.

gs.log() - In Logs

gs.info() - In Logs (mostly used for Scoped applications for logging as gs.log() does not work for scoped app)

gs.addInfoMessage() - On the form header in normal blue/green color

gs.addErrorMessage() - On the form header in red color

gs.print() - Mostly in background scripts for logging

Gaurav Shirsat
Mega Sage

Hello Ben

Is the script include in a scoped application If it is, then gs.log does not work and you should be using gs.info or gs.debug instead.

 You can send messages to customers as alerts, informative messages, or error messages.

1)current.field_name.setError("Hello World"); :-Will put "Hello World" below the specified field.

2)gs.addInfoMessage("Hello World"); :- Will put "Hello World" on the top of the screen.

3)gs.print("Hello World"); :-Will write to the text log on the file system but not to the sys_log table in the database.

4)gs.log("Hello World"); :-Will write to the Database and the log file.

https://docs.servicenow.com/bundle/orlando-application-development/page/script/general-scripting/ref...

What is System Log:-The System Logs module provides a variety of logs that you can use to troubleshoot and debug transactions and events that take place within the instance.

 https://docs.servicenow.com/bundle/orlando-platform-administration/page/administer/system-logs/conce...

 Please Follow The Steps:-
Application Navigator>System Logs>All...if filter Appears Remove it or check as per your requirement.
 
find_real_file.png
 

Please Mark Correct and Helpful

Thanks and Regards

Gaurav Shirsat