- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2018 02:58 AM
Hi,
I have created an after business rule that will automatically create a problem record once new INC is created with priority-new. Some of the details for problem record are taken itself from the same INC record.
The issue here is.How should i get this problem record getting linked with the incident automatically(getting problem "number" into "problem_id" field of incident form.I have tried the following script.Please let me know if I am missing any point.or what piece of code should I add to get this requirement done.
(function executeRule(current, previous /*null when async*/) {
var prbgr = new GlideRecord("problem");
prbgr.initialize();
prbgr.short_description = current.short_description;
prbgr.description = current.description;
prbgr.insert();
gs.addInfoMessage("New Problem created with number :" + prbgr.number);
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2018 03:15 AM
You can try this in after insert BR:
var prbgr = new GlideRecord("problem");
prbgr.initialize();
prbgr.short_description = current.short_description;
prbgr.description = current.description;
current.problem_id = prbgr.insert();
current.update();
gs.addInfoMessage("New Problem created with number :" + prbgr.number);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2018 03:13 AM
try this
(function executeRule(current, previous /*null when async*/) {
var prbgr = new GlideRecord("problem");
prbgr.initialize();
prbgr.short_description = current.short_description;
prbgr.parent=current.sys_id;
prbgr.description = current.description;
prbgr.insert();
gs.addInfoMessage("New Problem created with number :" + prbgr.number);
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2018 03:13 AM
You have to add current.problem_id = prbgr.sys_id; in your business rule.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2018 03:15 AM
You can try this in after insert BR:
var prbgr = new GlideRecord("problem");
prbgr.initialize();
prbgr.short_description = current.short_description;
prbgr.description = current.description;
current.problem_id = prbgr.insert();
current.update();
gs.addInfoMessage("New Problem created with number :" + prbgr.number);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2018 04:02 AM
Yes It worked. Will you please tell me what exactly happened in you code?