The CreatorCon Call for Content is officially open! Get started here.

insert() method returning null

Nisar2
Mega Guru

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:

  1. Logs print the sys_id as null 1 in 50 tries (just a calculated guess)
  2. 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.

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

15 REPLIES 15

Please close the thread, and mark corresponding thread as helpful/answered.