How can I print out a message in the system log?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2021 02:28 AM
Hi all, Im new to ServiceNow I would like some help with:
How can I print out a message in the system log?
The workflow assigned to this catalogue item should print out a log in the system logs to say "User <name of the user> has ordered more <RAM or CPU> for server <server name>". The same message should be written also in the Work Notes field of the Requested Item. Set the
state of the RITM to Closed complete after writing the messages in the previous step.
Many thanks!
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2021 02:30 AM
You can use :
gs.log() -> only work in global
gs.info() -> will work in all scope
gs.error() -> will work in all scope
Refer this URL:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2021 02:45 AM
Hi
Thanks for marking my response helpful.
If your query was solved please mark it correct as well so that other users having similar question will benefit from it.
Moreover you can use the following script for logging your message.
Just take the variable values accordingly.
var usr = user variable from your script
var ramOrCpu = ram or cpu value whatever is the value
var server_name = server name you want to print
// take all the values accordingly. Everytime your workflow will run this msg will be logged in log table
gs.info("User "+usr+" has ordered more "+ramOrCpu+" for server "+server_name);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2021 04:18 AM
Hi
In what kind of script do I have to put this code?
Thank you for your fast reply

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2021 04:37 AM
This can be put in any server side script.
Business Rule, Script include, scheduled jobs, workflow script, fix script etc.
Let us know where you are stuck and where you want to put this code?