'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

Mark Stanger
Giga Sage

The code above is saying to only populate those fields if they haven't been populated yet. If you want them to populate every time, just comment out the 2 'if' statement lines like this...



function setResolutionFields() {
//if (current.resolved_by.nil())
current.resolved_by = gs.getUserID();
//if (current.resolved_at.nil())
current.resolved_at = gs.nowDateTime();


germc
Giga Expert

Thanks very much - really appreciate that. It worked a treat


I'm glad that fixed it. One other thing to be aware of is that this script may also run on closure. If the fields are already populated on resolution, they will be overwritten on closure of the record. This is probably not something you want, so you might want to have 2 sections...one for when the ticket is set to closed (which only populates the values if they're empty) and one for when the ticket is set to resolved (which populates them new each time).


Something like this for your condition...



current.state.changesTo(6) || current.state.changesTo(7)

And something like this for the top of the script portion...


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();
}