how do I limit the time of when a user can reopen an incident i.e. after 30 days they can't reopen?

btreseder
Kilo Expert

how do I limit the time of when a user can reopen an incident i.e. after 30 days they can't reopen?

1 ACCEPTED SOLUTION

Sorry, i think i made a blunder here. I reversed the operator



replace this line


if(difference < thirtyDays )




with this




if(difference > thirtyDays )




I just cross checked it on a demo instance, it seems to work fine there


-Anurag

View solution in original post

21 REPLIES 21

Hi Brenda,



Create a NEW script include



Name - ReopenCondition


client callable - true


SCRIPT -


var ReopenCondition= Class.create();


ReopenCondition.prototype = Object.extendsObject(AbstractAjaxProcessor, {


reopentask: function()


{


var thirtyDays = 30*24*60*60;


var closedTime = incident.closed_at.getDisplayValue();


var currentTime = gs.nowDateTime();


var difference = gs.dateDiff(closedTime ,currentTime,true);


if(difference < thirtyDays )


{


return false;


}


else


{


return true;


}


}


});




Now in your ui action REOpen you already have this as the condition


current.incident_state == 9




Now write this ni the condition part


current.incident_state == 9 && (new ReopenCondition().reopentask())


-Anurag

I've done what you suggested but it didn't work. I opened a closed incident and the button is still there and it was closed over 30 days ago.


there is an oob field on incident "Closed" what is the value on that field?? I wrote my script on that field.



var closedTime = incident.closed_at.getDisplayValue();




If you are using any other field to check the date on which it was closed use that field in this line in the place of "closed_at"


-Anurag

Ours is also 'closed_at' for the value.


and when you open and again close the incident...i think this value will get the current date time....The Incident you tested this, can you check what value does this field have for it.


-Anurag