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 03:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 04:01 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 12:51 AM
When you create a table in scoped application it's name would be like this:
Make sure you are using correct name in your scipt.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 12:59 AM
The name is correct. In the actual script, the name is x_spit_devops_si_o_si_support.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2022 05:12 AM
Have you managed to figure it out?
If the table has been created in a scoped application, the table name does have the scope prefix (as mentioned by
If the table has been created in the global scope, the table name has a u_ prefix (e.g. in your case: u_support_ci).
try {
var newSupportCiGr = new GlideRecord('u_support_ci');
newSupportCiGr.newRecord();
newSupportCiGr.po_number = "po number";
newSupportCiGr.model_id = cmdb_model_sys_id;
newSupportCiGr.operational_status = 1;
newSupportCiGr.name = "some name";
var newSupportCiSysId = newSupportCiGr.insert();
} catch (e) {
gs.error(e.message);
}
Note: try to (1) declare variables, (2) use camel case for variable names (in order to avoid name clashes with field names).