Date should capture when the incident is resolved

manisha3014
Kilo Contributor

Hi   All....on incident form i have to create a new field called "Last Resolved' on the Incident page which should capture the date when the Incident was last marked as resolved. Please help me in this.

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

Hi Manisha,



one quick question.


why do you need to capture the date in your last resolved field.


there is OOTB field "closed" you can use that field also to update the exact resolved time of your incident.


just you need to mention the condition in business rule.



current.closed_at = gs.nowDateTime();


below screenshot for your Resolved At field.



find_real_file.png


View solution in original post

25 REPLIES 25

Siddartha Gudim
Tera Guru

Hi Manisha,



Please create a new business rule (before)



condition -->> current.incident_state == IncidentState.RESOLVED   || current.incident_state == IncidentState.CLOSED



script -->


function onBefore(current, previous) {



    if (current.fieldname.nil())


          current.fieldname= gs.nowDateTime();



}



The above script captures the resolved time when ever the incident is resolved.


and it also takes care of incidents which are directly closed by adding the closed time to resolved field.



Please like or mark correct based on the impact of response.


Thank you so much....


Thank you so much....


gangaprathap
Tera Contributor

Hi Maneesha,



Just write a business rule(Insert and Update) on that table and select 'advanced' and write the following script.



(function executeRule(current, previous) {




  if(current.state==numofResovedState)                                                                                                      


  {


  current.Fieldname=new GlideDateTime().getDisplayValue();//setting the resoved time to that field


  }




})(current, previous);



And make that field 'read-only' in dictionary option..so that the resolved time field can not be editable.



Pls mark Correct and helpful...If the answer fufills ur need.



Thanks


Gangaprathap Yadav


Hi Pratap,



Thank you so much. it worked for me..I need only Date not time. How can i do that one.?