- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 10:06 AM
Hi There!
I need to create Incident based on Requested Item, using Business Rule, something like this:
var gr = new GlideRecord('incident');
gr.initialize();
gr.assignment_group = current.assignment_group;
gr.insert();
current.u_has_incident = true;
I have a problem with field "Has incident", which is not a form field. Without current.update() at the end, it will not be changed. On the other hand I saw few articles with advice not to use current.update() in Business rules... what should I do then to make it work?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 09:35 PM
Use an after business rule to create the incident as following
var gr = new GlideRecord('incident');
gr.initialize();
gr.assignment_group = current.assignment_group;
// add your fields that has to be ampped
gr.insert();
current.u_has_incident = true;
current.update();
current.setWorkflow(false);
The last will prevent any business rule or workflow condition to execute.
Please like or mark correct based on the impact of the response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 06:26 PM
Hi jakub,
current.update() can be used if it is onAfter Business Rule.
Write onBefore() Business Rule on sc_req_item.
var gr = new GlideRecord('incident');
gr.initialize();
gr.assignment_group = current.assignment_group;
gr.u_problem = gr.sys_id;
gr.insert();
var prob_gr = new GlideRecord('problem');
prob_gr.addQuery("u_problem",gr.sys_id);
prob_gr.query();
if(prob_gr.next())
{
prob_gr.u_has_incident = true;
prob_gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2017 09:35 PM
Use an after business rule to create the incident as following
var gr = new GlideRecord('incident');
gr.initialize();
gr.assignment_group = current.assignment_group;
// add your fields that has to be ampped
gr.insert();
current.u_has_incident = true;
current.update();
current.setWorkflow(false);
The last will prevent any business rule or workflow condition to execute.
Please like or mark correct based on the impact of the response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2017 09:26 AM
Hi Jakub,
what action on your requested item should trigger an incident to be created?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2017 03:11 AM
Thank you everyone for your valuable input!
Finally, I've created a business rule which on Incident insert (after) which uses GlideRecord query to flag RITM and update() glide record.
Thanks again!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2017 05:24 AM
HI Jak,
Please mark answer as correct and close the thread accordingly.
Thank you,
Ashutosh