'Resolved' & Resolved by' fields not updating when call is resolved multiple times

germc
Giga Expert

Hi guys, Has anyone noticed that the 'Resolved' & Resolved by' fields are not updating when a call is resolved multiple times.
For example, If I resolve an incident at 14.55 it says:
Resolved: 14.55
Resolved by: me
However, if jobloggs reopens and then resolved again at 17.00 it still shows as:
Resolved: 14.55
Resolved by: me
But it should show as:
Resolved: 17:00
Resolved by: jobloggs

It should always show the last person who resolved it and also the last time it was resolved, not the first.
I have checked the business rule for this and think the following script is doing it:
function setResolutionFields() {
if (current.resolved_by.nil())
current.resolved_by = gs.getUserID();
if (current.resolved_at.nil())
current.resolved_at = gs.nowDateTime();

Is there a way to modify this script so that the last person to resolve is shown, not the first?

7 REPLIES 7

Thank you so much for your help on this.
I have implemented the below script and got the following results when the incident autoclosed:
The 'resolved at' time updated to the closure date instead of staying at the resolved date.
The 'Closed by' filed just stayed blank.
The main thing is the 'resolved at' field. This should update every time a call is resolved but not update when it autocloses (only the 'closed by' should update then)
I have 2 business rules:
'Mark_resolved' & 'mark_closed'

Mark_resolved:
Condition:
current.incident_state.changesTo (6) || current.incident_state.changesTo (7)
Script:
setResolutionFields();

function setResolutionFields() {
if(current.state == 6){
//Re-populate resolution fields every time
current.resolved_by = gs.getUserID();
current.resolved_at = gs.nowDateTime();
}
else{
if (current.resolved_by.nil())
current.resolved_by = gs.getUserID();
if (current.resolved_at.nil())
current.resolved_at = gs.nowDateTime();
}

// Update the fields that indicate the time and duration of this incident from open to resolve.
// Keep track of duration as a glide_duration value (dd hh:mm:ss) and as a pure number of seconds.
// Both calendar time and business time are maintained.

var dataChange = current.opened_at.changes() || current.resolved_at.changes();
var opened = current.opened_at.getDisplayValue();
var resolved = current.resolved_at.getDisplayValue();

if (dataChange || current.business_duration.nil())
current.business_duration = gs.calDateDiff(opened, resolved, false);

if (dataChange || current.business_stc.nil())
current.business_stc = gs.calDateDiff(opened, resolved, true);

if (dataChange || current.calendar_duration.nil())
current.calendar_duration = gs.dateDiff(opened, resolved, false);

if (dataChange || current.calendar_stc.nil())
current.calendar_stc = gs.dateDiff(opened, resolved, true);
}

mark_closed
Condition:
current.incident_state == 7
Script:
setClosureFields();

function setClosureFields() {
// incident_state is Closed so
// 1. mark the task as inactive
// 2. set the closed by to current user if not supplied
// 3. set the closed time to now if not supplied
current.active = false;
if (current.closed_by.nil())
current.closed_by = gs.getUserID();
if (current.closed_at.nil())
current.closed_at = gs.nowDateTime();

// Update the fields that indicate the time/duration of the incident from open to close.
// Keep track of duration as a glide_duration value (dd hh:mm:ss) and as a pure number of seconds.
// Both calendar time and business time are maintained.

var dataChange = current.opened_at.changes() || (current.closed_at.changes() && !current.isValidField("resolved_at"));
var opened = current.opened_at.getDisplayValue();
var closed = current.closed_at.getDisplayValue();

if (dataChange || current.business_duration.nil())
current.business_duration = gs.calDateDiff(opened, closed, false);

if (dataChange || current.business_stc.nil())
current.business_stc = gs.calDateDiff(opened, closed, true);

if (dataChange || current.calendar_duration.nil())
current.calendar_duration = gs.dateDiff(opened, closed, false);

if (dataChange || current.calendar_stc.nil())
current.calendar_stc = gs.dateDiff(opened, closed, true);
}


I changed my business rule to do the same.   It works great but I'm back on the community because if the assigned_to adds a note (after it's set to resolve), it updates the Resolved Time.   We have another business rule that will change the state to Customer Responded IF they are not the assigned_to.   I'm not sure where I'm going wrong with this BR.   Like I said works as I want it EXCEPT if the assigned_to adds a note.   I don't want it to update the Resolved Time field.



Thoughts?


We have found that applying the code to update the Resolved By/At fields each time also updated these details at auto close. This meant that the System user would populate both the Resolved and Close details at auto close. To get around this we added a condition to the if statement which would not update the Resolved By/At fields if the user is System.



var cId = gs.getUserID();



if((current.state == 6 ) && (cId != "system")){  


          //Re-populate resolution fields every time if state is resolved and user IS NOT System


      current.resolved_by = gs.getUserID();  


      current.resolved_at = gs.nowDateTime();  


    }  


    else{  


          if (current.resolved_by.nil())  


              current.resolved_by = gs.getUserID();  


          if (current.resolved_at.nil())  


                current.resolved_at = gs.nowDateTime();  


    }