Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Can we make work notes filed mandatory when updating Time Worked field

abusaleh_quader
Tera Contributor

Hi 

I want to make Work Notes field mandatory if there any changes in Time worked field. I have tried this onchange client script but it is not working. Here I made field name as Time Worked.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

   //Type appropriate comment here, and begin script below
  
   g_form.setMandatory('work_notes', true);
   
   
}
 
 
#Screenshot
abusaleh_quader_0-1721418308482.png

 

1 ACCEPTED SOLUTION

Bert_c1
Kilo Patron

Hi @abusaleh_quader,

 

The 'time_worked' field on task and all of its child table is type "Timer".  Your client script works on a string field, but not 'time_worked' on any task record due to it being type "Timer". You will need another means to achieve your goal.  Maybe a business rule that runs and displays an Error and aborts the transaction if that value changes and 'work_notes' is empty.

 

View solution in original post

5 REPLIES 5

Here's a BR, A client script doesn't work for that field.  My BR is defined on a custom child table of task.

 

Screenshot 2024-10-07 103222.png

 

Screenshot 2024-10-07 103940.png

Not the best user experience, since the field is a Timer. And a test of the BR indicates the 'time_worked' field must be present on the form.