Set duration field using client script - Display and Set

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2019 04:02 AM
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
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2019 04:08 AM
Hi
Is it a field on the form or a variable?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2019 04:40 AM
It is a field on the form.