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

bammar
Kilo Sage
Kilo Sage

You must evaluate the time worked field- ie add another line that checks if its changed from default value/blank/ 00:00:00/ . Then if it is not the default value then you require the work notes. - You are watching for a change and you got the end, but the middle part is evaluating the value .

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.

 

Thanks we have created a business rule and client script. It's working.

Jana_S
Tera Expert

@abusaleh_quader Hi, we are trying to achieve something similar, would you be able to share you client script and business rule with me please?