"Time Worked" field to be made Mandatory at the time of closure of Incident ticket

hemanthrajg
Kilo Contributor

"Time Worked" field to be made Mandatory at the time of closure of Incident ticket

Disable the Auto Timer for Time Worked Field in Incident Table

Make the Time Worked Field mandatory only for Incidents.

10 REPLIES 10

scottstahr
Giga Contributor

You could create a UI Policy on the incident table that is triggered when the incident's state changes to "Resolved" or "Closed".   Add a UI Policy action to the policy to make the Time Worked field mandatory.


Creating a UI Policy - ServiceNow Wiki


Stacy1
Mega Guru

Hi,



We wrote a client script on submit.   Here is our code.   We are using the related list for time worked on our incidents.



function onSubmit(){


if (g_form.getValue('state')==6 && g_user.hasRole('itil')){


if (g_form.getValue('close_code')!='Resolved - Resolved/Closed by User' && g_form.getValue('close_code')!='Resolved - Duplicate Ticket'){


var curSysid = g_form.getUniqueValue();


// alert ("Unique is " + curSysid);


var ga = new GlideAjax('check_timeworked_exists');


ga.addParam('sysparm_name','check_timeworked_exists');


ga.addParam('sysparm_currentsysid', curSysid);


ga.getXMLWait();



var answer = ga.getAnswer();


if(answer == 'Not Exist')


{


g_form.addErrorMessage('Please enter time worked');


return false;


}


}


}


}



Thanks,


Stacy


hi stacy,



Do we require script include for this, if yes pls send script include script for the same.


and one thing ,in time worked field "00.00.00" it looks like this if i make it mandate it is not working properly


Stacy1
Mega Guru

Yes sorry.   Here is the script include information:



Name:check_timeworked_exists


Script:


var check_timeworked_exists = Class.create();




check_timeworked_exists.prototype = Object.extendsObject(AbstractAjaxProcessor,


{


check_timeworked_exists: function()


{


var answer ='';


var cursysid = this.getParameter('sysparm_currentsysid');



gs.log('cursysid :'+cursysid);



var gr = new GlideRecord('task_time_worked');


gr.addQuery('task', cursysid);


gr.query();


if(!gr.next())


{


answer = "Not Exist";


}


else


{


answer = "Exist";


}


return answer;


}


});