- 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-28-2020 03:51 AM
you can just log a if condition
var task = new GlideRecord('u_my_table');
task.newRecord(); // Try changing it to newRecord()
task.u_name = "Test";
var sys_id = task.insert();
if(!sys_id )
gs.log(task.u_name +"SysId: "+ sys_id )
--and can cehck for which name value it is givingn null value and then try creating the same record from background scripts, might get some hint.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 03:32 AM
One in 50 tries!Looks like Servicenow is unhappy.
Although it should return sys_id every time.
Record is getting created or not?
When it returns null
Thanks
Sudhanshu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2020 03:43 AM
No, record is not getting created when null is received.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2020 03:25 PM
I just came across similar behavior today. Mine happens with the cmdb_rel_ci table on Orlando, and yes, the record ALWAYS gets created successfully! Have you opened a HI ticket yet?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2020 03:40 PM
The problem may be high load on your instance. Better contact HI and ask for their help.