- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2020 04:28 AM
Hi,
I have many incidents in one Servicenow instance. I want to create Problem from one incident and link other related incidents to this problem. I want to do this all not by UI. But by any REST API or by any Script triggered on REST API call.
Please help me to guide on how can I create problem from Incident by Script or API. and also for linking.
Thanks in Advance,
Viral Patel
Solved! Go to Solution.
- Labels:
-
Instance Configuration
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2020 05:32 PM
You can configure business rule on incident table to create problem.
Use below business rule script to create problem from master incident and related same problem to child incidents.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var prb = new GlideRecord('problem');
prb.initialize();
prb.short_description = current.short_description;
prb.description = current.description;
prb.cmdb_ci = current.cmdb_ci;
prb.problem_state = "1";
prb.assignment_group = current.assignment_group;
var pr = prb.insert();
current.problem_id = pr;
var child = new GlideRecord('incident');
child.addQuery('parent_incident',current.sys_id);
child.query();
while(child.next()){
child.problem_id = pr;
child.update();
}
})(current, previous);
Regards,
sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2020 05:32 PM
You can configure business rule on incident table to create problem.
Use below business rule script to create problem from master incident and related same problem to child incidents.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var prb = new GlideRecord('problem');
prb.initialize();
prb.short_description = current.short_description;
prb.description = current.description;
prb.cmdb_ci = current.cmdb_ci;
prb.problem_state = "1";
prb.assignment_group = current.assignment_group;
var pr = prb.insert();
current.problem_id = pr;
var child = new GlideRecord('incident');
child.addQuery('parent_incident',current.sys_id);
child.query();
while(child.next()){
child.problem_id = pr;
child.update();
}
})(current, previous);
Regards,
sachin