- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2020 08:50 AM
When problem created from incident the notifications about problem progress will send to first reported by incident's caller.I want to send these notification to all child incident linked with first reported incident.
var first_reported_by_task = current.first_reported_by_task.getDisplayValue();
var gr = new GlideRecord('incident');
gr.addQuery('problem_id',current.sys_id);
gr.query();
while(gr.next())
{
if(gr.number==first_reported_by_task){
var callerid =gr.getDisplayValue('caller_id.email');
var openby=gr.getDisplayValue('opened_by.email');
gs.eventQueue('Fired.caller.opendby.from.incident',current,callerid,openby);
}
}
How can I modify this.
Please help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2020 09:24 AM
Hi jack,
Try this code.write business rule on problem table
var problemid =current.sys_id;
var au =new ArrayUtil();
var list =[];
var gr =new GlideRecord('incident');
var q1 =gr.addQuery('problem_id',current.getValue("sys_id"));
q1.addOrCondition('parent_incident.problem_id',current.getValue("sys_id"));
gr.query();
while (gr.next()) {
list.push(gr.getDisplayValue('caller_id.email'));
list.push(gr.getDisplayValue('opened_by.email'));
}
var shortList = au.unique(list);
for (var i =0; i<shortList.length;i++) {
gs.eventQueue('event name',current,shortList[i],problemid);
}
Email script:
var inc =new GlideRecord('incident');
var q2 =inc.addQuery('problem_id',event.parm2);
q2.addOrCondition('parent_incident.problem_id',event.parm2);
var q1 =inc.addQuery('caller_id.email',event.parm1);
q1.addOrCondition('opened_by.email',event.parm1);
inc.query();
while(inc.next()) {
var number,state;
if(inc.problem_id==event.parm2) {
number=inc.getDisplayValue('number');
state=inc.getDisplayValue('state');
} else {
number=inc.getDisplayValue('parent_incident');
state=inc.getDisplayValue('parent_incident.state');
}
template.print('Incident Number: ');
template.print(number);
template.print('<br>');
template.print('Incident State: ');
template.print(state);
template.print('<br>');
}
And call this email script in notification
Regards,
Monali Patil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2020 09:24 AM
Hi jack,
Try this code.write business rule on problem table
var problemid =current.sys_id;
var au =new ArrayUtil();
var list =[];
var gr =new GlideRecord('incident');
var q1 =gr.addQuery('problem_id',current.getValue("sys_id"));
q1.addOrCondition('parent_incident.problem_id',current.getValue("sys_id"));
gr.query();
while (gr.next()) {
list.push(gr.getDisplayValue('caller_id.email'));
list.push(gr.getDisplayValue('opened_by.email'));
}
var shortList = au.unique(list);
for (var i =0; i<shortList.length;i++) {
gs.eventQueue('event name',current,shortList[i],problemid);
}
Email script:
var inc =new GlideRecord('incident');
var q2 =inc.addQuery('problem_id',event.parm2);
q2.addOrCondition('parent_incident.problem_id',event.parm2);
var q1 =inc.addQuery('caller_id.email',event.parm1);
q1.addOrCondition('opened_by.email',event.parm1);
inc.query();
while(inc.next()) {
var number,state;
if(inc.problem_id==event.parm2) {
number=inc.getDisplayValue('number');
state=inc.getDisplayValue('state');
} else {
number=inc.getDisplayValue('parent_incident');
state=inc.getDisplayValue('parent_incident.state');
}
template.print('Incident Number: ');
template.print(number);
template.print('<br>');
template.print('Incident State: ');
template.print(state);
template.print('<br>');
}
And call this email script in notification
Regards,
Monali Patil