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 04:52 AM
I tried to use a Script include. where exactly should I put your code? And what options should i mark (client callable, caller access ect...)?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2021 02:34 AM
Hi Med,
You can try using gs.info('message','source'). This will also add a log record in the sys_log table.
Regards,
Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2021 02:48 AM
Hi,
it would be like this
Ensure you give the variable name which has choices as RAM or CPU and the server variable
var message = 'User ' + current.request.requested_for.name + ' has ordered more ' + current.variables.variableName + ' for server ' + current.variables.serverVariable.getDisplayValue();
current.work_notes = message; // for setting in work notes
gs.info(message); // for printing in logs
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
‎04-02-2021 04:18 AM
Hi
In what kind of script do I have to put this code?
Thanks for the reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-02-2021 04:36 AM
Hi,
in the workflow run script.
the workflow is for your catalog item
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader