"Time Worked" field to be made Mandatory at the time of closure of Incident ticket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2017 07:32 AM
"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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2017 07:38 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2017 08:17 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2017 11:43 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2017 12:04 PM
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;
}
});