- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2020 09:03 AM
Hello
I have an issue, when I close an incident, the interaction related to that incident does not close, where do I check this please.
Solved! Go to Solution.
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2020 02:11 AM
Ok,
Then the BR is on Incident table. After - Update
Condition: incident is closed
Script:
ar gr = new GlideRecord('interaction'); //check table name
gr.addQuery('sys_id', current.u_interaction);
gr.addQuery('active', true);
gr.query();
while(gr.next()) //if there is only 1 interaction, you can use if instead of while
{
gr.state = 3; //check closure state value
gr.comments = 'Interaction Closed'; //optional
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2020 09:45 AM
You can write a business rule to do so.
After update business rule On the interaction table
Condition: Parent is not empty, assuming parent is the field how you map incident and interaction
AND Interaction state <changes to> closed
Script:
var gr = new GlideRecord('incident')
gr.addQuery('sys_id', parent,sys_id);
gr.query();
if(gr.next())
{
gr.incident_state = 3;
gr.update()
}
PS: This is all example, be sure you check that you use the right field names . Also you will need to check if there are more than one interactions associated to incident, then all must be closed before you close the incident.
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2020 12:59 AM
Hello Anurag,
Thank you for your answer.
Actually, for one interaction i can have one or many incident or request attached to this interaction.
The interaction must be closed if all incident and req are closed.
we tried this BR but unfortunately it s not working 😞
(function executeRule(current, previous /*null when async*/) {
var result = [];
var array = [];
var ref = [3];
var gr = new GlideRecord ('task');
gr.addQuery('u_interaction',current.u_interaction);
gr.query();
while (gr.next())
{
array.push(gr.state);
}
if(array.length > 0)
{
for(var i=0;i<array.length;i++)
{
var arrayUtil = new ArrayUtil();
if(arrayUtil.indexOf(ref, array[i])==-1)
{
result.push(array[i]);
}
}
}
if(result.length == 0)
{
var inter = new GlideRecord ('interaction');
inter.addQuery('sys_id',current.u_interaction);
inter.query();
if(inter.next())
{
inter.state='closed_complete';
inter.update();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2020 01:19 AM
Hi,
Keep request and incident separately. Lets do it for Incident and then you can repeat the same for Request.
From what I understand, One interaction can be associated to many incidents.
Can one incident have more than 1 interaction?
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2020 01:29 AM
Hi,
No, an incident can be associated to only one interaction