- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 07:37 AM
How do i log my code so i can see in system logs where my script goes wrong?
(function executeRule(current, previous /*null when async*/ ) {
var grL = new GlideRecord('u_leiekategori');
var a = current.u_maanedspris;
grL.u_gjeldene_leiepris = a;
grL.update();
})(current, previous);
i wanna log this so i can view where the error happens.
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 07:44 AM
Hi,
Out of box, if there's an error here it'll automatically be captured in the system log.
However, based on what you're doing with GlideRecord, this may not throw an error and instead it'll create a record (because you didn't format this correctly to successfully query the table and are trying to "update" nothing...so a new record would be created).
You can insert your own logging though by using example:
(function executeRule(current, previous /*null when async*/ ) {
gs.info("***DEBUG - Hi I'm at the start of this script");
var grL = new GlideRecord('u_leiekategori');
var a = current.u_maanedspris;
gs.info("***DEBUG - This is the value set for JavaScript variable 'a': " + a);
grL.u_gjeldene_leiepris = a;
grL.update();
gs.info("***DEBUG - Bye!");
})(current, previous);
So the above shows 3 places I'm logging things.
Otherwise, you may want to review using a try catch: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 08:02 AM
Do you want to update all the rows of that table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 08:06 AM
No just the one u_gjeldene_leiepris to be updated with the same value as u_maanedspris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 07:44 AM
@asd
You can use this syntax:
gs.info('Your code here');
You can see your logs under System Log> All
syslog.list
Thanks
Murthy
Murthy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 07:44 AM
Hi,
Out of box, if there's an error here it'll automatically be captured in the system log.
However, based on what you're doing with GlideRecord, this may not throw an error and instead it'll create a record (because you didn't format this correctly to successfully query the table and are trying to "update" nothing...so a new record would be created).
You can insert your own logging though by using example:
(function executeRule(current, previous /*null when async*/ ) {
gs.info("***DEBUG - Hi I'm at the start of this script");
var grL = new GlideRecord('u_leiekategori');
var a = current.u_maanedspris;
gs.info("***DEBUG - This is the value set for JavaScript variable 'a': " + a);
grL.u_gjeldene_leiepris = a;
grL.update();
gs.info("***DEBUG - Bye!");
})(current, previous);
So the above shows 3 places I'm logging things.
Otherwise, you may want to review using a try catch: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2022 07:49 AM
Hi,
Please review GlideRecord documentation for assistance with that piece: https://developer.servicenow.com/dev.do#!/reference/api/paris/server/no-namespace/c_GlideRecordScope...
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!