- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2022 01:50 PM
I have a Script Include which queries an external database for alert conditions and uses GlideRecord inserts to create an Incident for each device returned. The script also uses a GlideRecord insert create a Problem. I would like to then insert the Incidents that were created by the script into the related list for the Problem that was created by the script.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2022 02:10 PM
Hi, the problem related list for incident is simply the incident table filtered for records where the incident.problem_id field is populated with the current problem record,
Without your code it is not possible to identify the changes you would need to make,
but as long as you insert your problem record first then all you should need to do is populate the sys_id from your problem insert into the incident.problem_id field
var test = new GlideRecord('problem');
test.initialize();
test.short_description = ‘testing’;
test.insert();
gs.info(test.sys_id);
var test2 = new GlideRecord('incident');
test2.initialize();
test2.short_description = ‘testing’;
test2.problem_id = test.sys_id;
test2.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2022 02:10 PM
Hi, the problem related list for incident is simply the incident table filtered for records where the incident.problem_id field is populated with the current problem record,
Without your code it is not possible to identify the changes you would need to make,
but as long as you insert your problem record first then all you should need to do is populate the sys_id from your problem insert into the incident.problem_id field
var test = new GlideRecord('problem');
test.initialize();
test.short_description = ‘testing’;
test.insert();
gs.info(test.sys_id);
var test2 = new GlideRecord('incident');
test2.initialize();
test2.short_description = ‘testing’;
test2.problem_id = test.sys_id;
test2.insert();