insert() not working after initialize.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 09:45 AM
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?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 10:58 AM
Are you in scoped application?
On Mon, Mar 6, 2017 at 12:57 tahnalos <community-no-reply@servicenow.com>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 11:00 AM
The two tables identified in the script are part of an application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 11:18 AM
CORRECTION: u_sec_eq_rel is part of the global application. u_ss_equipment_detail came with a different application.
Does insert() have limitations in this regard?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 11:21 AM
Where is this code in? Global or scoped?
On Mon, Mar 6, 2017 at 13:19 tahnalos <community-no-reply@servicenow.com>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2017 11:23 AM
I believe it is in the application. The code is being used in a business rule that runs from a form in the same application as u_ss_equipment_detail.
Think I need to add u_sec_eq_rel to the application.