Set duration field using client script - Display and Set

Sagar Patro
Kilo Guru

Hello Everyone,

Every time I have worked with duration fields, it is challenging in some type 🙂 This time it is modifying the duration field value based on a start date and end date.

Ideally, we set the value for duration fields like this

g_form.setValue('<duration_field>','1 01:00:00');

This sets the value for the field correct but the problem is the display style of it.

The end-user also seems to see the duration as '1 01:00:00' instead of 25hours/1day 1 hour which is the desired format.

If I am setting the value from client script as "1 01:00:00" then on saving the form, I get the desired format. 

If I am setting the value from client script as "25hours" then on saving the form, the value is not saved.

How do I show the user the desired format and also make servicenow understand to save the right value?

 

Thank you for your help.

 

-Vidyasagar

ZeTechno

 

2 REPLIES 2

Omkar Mone
Mega Sage

Hi 

Is it a field on the form or a variable?

 

It is a field on the form.