insert() not working after initialize.

tahnalos
Kilo Sage

Trying to insert a new record using a string that contains a sys_id obtained through a third party process.   The sys_id exists on the table being referred to but I can't seem to get the insert to work.   Both u_sector and u_eq_detail are reference fields, and sector is itself passed into the function in question.   The following code is in a non client-callable script include:

var gr1 = new GlideRecord ('u_sec_eq_rel');

var gr2 = new GlideRecord ('u_ss_equipment_detail');

gr1.initialize();

gr2.get('string sys id from third party app');

gr1.u_sector = sector;

gr1.u_eq_type = eq_type;

gr1.u_eq_detail = gr2.sys_id;

gr1.u_quantity = 1;

gr1.insert(); <== error occurs here.

I keep getting this error: org.mozilla.javascript.EcmaError: 3 is not a function.

Whereas the number referred to is random.

Ideas?

15 REPLIES 15

She Sull
Giga Guru

You have not queried the gr2 table for the sys_id. How does this function know what sys_id to get?   Or do you want to hard code the sys_id?


As mentioned earlier, the sys_id from the gr2 table is obtained through a third party app that drops the data in a field in another table.   The get is supposed to leverage that sys_id.



Thanks


So you have sys_id of the record in 'u_ss_equipment_detail' table from the third party right?


Yes.