Cannot insert a record in a custom table using while the record can be inserted in the parent table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2022 11:25 PM
Hello,
I created code that inserts a new record in a custom class. This class is a child class of cmdb_ci. The code looks like this:
new_si_support_record = new GlideRecord('support_ci');
new_si_support_record.newRecord();
new_si_support_record.po_number = "po number";
new_si_support_record.model_id = cmdb_model_sys_id;
new_si_support_record.operational_status = 1;
new_si_support_record.name = "some name";
new_si_support_record_sys_id = new_si_support_record.insert();
This does not work. When I change the first line to:
new_si_support_record = new GlideRecord('cmdb_ci');
it does work.
The support_ci table is created in its own application/scope. So I checked the settings for application access on the table and enabled everything to be sure.
But still, I was unable to create a new record in the 'support_ci' table.
Because I am able to insert records into the cmdb_ci table, I assume the code is correct and the 'cross scope privileges' are sufficient.
What could be wrong?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 12:26 AM
What Target Scope should I use? Is it Global or the scope in which the support_ci table is created?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 12:29 AM
Target scope should be Global.
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 12:31 AM
Your record would look like this:
Create cross scope in Scoped Application.
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 12:31 AM
Try the below code to see if there is any error.
try {
new_si_support_record = new GlideRecord('support_ci');
new_si_support_record.newRecord();
new_si_support_record.po_number = "po number";
new_si_support_record.model_id = cmdb_model_sys_id;
new_si_support_record.operational_status = 1;
new_si_support_record.name = "some name";
new_si_support_record_sys_id = new_si_support_record.insert();
} catch (e) {
gs.error(e.message);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 12:36 AM
Also, paste the top part of the Table definition that has "Label", "Name", "Extends table", and "Application" fields.
I've been extending Configuration Item table and have been able to insert records without any problem.
"This does not work. " is too vague. It's necessary to post the explicit error message to be able to find the problem.