- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2020 11:15 PM
Hi experts,
A strange behaviour is driving me nuts. I've the following code inside a SI
var task = new GlideRecord('u_my_table');
task.initialize();
task.u_name = "Test";
var sys_id = task.insert();
gs.log(sys_id, "ABC");
The problem here is two fold:
- Logs print the sys_id as null 1 in 50 tries (just a calculated guess)
- Logs print the sys_id as expected the remaining times
So, I wonder what is causing it to fail that one time and if it is possible to know the reason why it failed?
I tried looking at logs (during the timeframe at which the insert happened) and did not find any warning/error level data.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 03:12 AM
Hi Nisar,
It's strange.
Do you have any before insert BR on that table or any data policy applied on that table.
Ideally it should give you the sys_id everytime.
If that is the case please raise a HI ticket with ServiceNow if this is for your client instance.
Do let us know the updates.
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
‎07-30-2020 03:51 PM
Hi
On what type of object are you seen this type of error (business rule? background script? fixed script? ... other?)
On the past I have seen a similar behavior specially when using fixed scripts or a background script when looping with updates/inserts through a very large of records that required an update. (Yes, updating the cmdb is a great example of that).
After those experiences I learned three things:
a) Sometimes is better to batch the updates/insert in smaller chunks.
b) For some reason executing the code through a on demand scheduled job was more reliable than other methods. You may want to try this out and see if you get a more reliable result.
c) You may want to try to add routines that insert a little bit of delay between the insert / update operations. (you know... so that ServiceNow doesn't go nuts :P).
I hope this helps!!
Thanks,
Berny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2020 04:03 PM
Agreed with points you've mentioned.
Points you've mentioned all seems to point to load on the instance. People often forget when programming on the cloud that in reality, there's resource limitation.
These limitation were more visible when we were programming on on-premise servers because we were monitoring them more closely.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2020 10:28 PM
@ Nisar, I think you need to close this thread or kindly update with your further observations. It helps other members.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2020 01:30 AM
I've figured out the cultprit. It was indeed a "before" BR that will cancelling the insert.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-06-2020 02:27 AM
Thanks for the update. I was wondering what the problem was because this can't be allowed in production system and I sure don't want to encounter it.