Sys id returned but record does not exist

gianlucagil
Tera Contributor

I have a strange behaviour when trying to create a record: everything seems to work fine but the record is not actually created, though insert() method returns a sys id. How can I find what's happening?

This is the code

 

var taskGr = new GlideRecord('wm_task');

taskGr.initialize();
taskGr.u_snj_mandatory_task = false;
taskGr.short_description = taskDescription;
taskGr.u_snj_request_type = requestType;
taskGr.parent = woSysId;
taskGr.state = 1;
taskGr.substate = 10;
taskGr.u_snj_model_requested = woModel;
taskGr.u_snj_stockroom = woStockroom;
taskGr.assigned_to = woAssignTo;
taskGr.assignment_group = woAssignmentGroup;
var insertedId = taskGr.insert();

 

I show  insertedId on a UI message and it does have a value, but there are no records on the table

1 ACCEPTED SOLUTION

Collin Romeijn
Kilo Guru

Hi,

most likely there is some business rule or acl that prevents you from creating/inserting a record in the table. So check those table configurations.
initialize or using a .do reserves a sysid + recordnumber... but when you abort the action nothing is created.

Hopefully this gives you some guidons.

Kind regards,

Collin

View solution in original post

6 REPLIES 6

Collin Romeijn
Kilo Guru

Hi,

most likely there is some business rule or acl that prevents you from creating/inserting a record in the table. So check those table configurations.
initialize or using a .do reserves a sysid + recordnumber... but when you abort the action nothing is created.

Hopefully this gives you some guidons.

Kind regards,

Collin

Hi Collin,

thanks for your answer. As you may guess I am quite newbie to ServiceNow. I actually thought something about that, and I see that there are many BR's on that table. I wonder if either an 'after' BR is able to abort record insertion, or if a 'before' one is needed for that.

Hi Collin,

thanks for your answer. As you may guess, I'm quite a newbie to ServiceNow. I actually thought something like that, and I see that many BR's are present on that table. I am wondering if either an 'after' BR is able to abort record insertion, or if a 'before' one is needed.

Hi Collin, 

thanks for your answer. As you may guess I am quite a newbie to ServiceNow. I actually thought something like that, and I see many BR's are present on that table. I am wondering if either an 'after' BR is able to abort record insertion, or if a 'before' one is needed.