About Duration field

Not applicable

How to set and get value of duration field ?
(In wiki they provide on example to set value
ie current.u_time_to_assign.setDisplayValue('3 04:30:14') but it is not working )

How to perform calculation on duration field ?

How to convert integer to duration ?

4 REPLIES 4

Valor1
Giga Guru

Here are a couple notes on Duration fields:

Here's how you can calculate a duration. By default, durations are stored in miliseconds. By using the same syntax, you can perform about any type of calculation.
http://wiki.service-now.com/index.php?title=Duration_field_addition
Note that the example is using the actual "duration" field, as well as the "dateNumericValue()" function.

In general, times needed to be converted to an integer in order to do calculations, and then maked as a glide_duration type field in order to be shown as a human-readable format.
http://wiki.service-now.com/index.php?title=Durations_and_personalize_calculations

Essentially, you're just setting a field attribute to "format=glide_duration" for display.


Not applicable

Hi, I want to reset a duration field to 0 and tried the above mentioned two ways but nothing seems to work.
First I tried :-
g_form.setDisplayValue('calendar_duration', '0 00:00:00');

Also tried to follow the instructions on the link:-
http://wiki.service-now.com/index.php?title=Duration_field_addition

Any suggestions on resetting the duration to 0 will be appreciated.
Thanks,
Shilpi.


Are you trying to set the field via a Client Script, or a Business Rule? The syntax is different for both.


Hi,
Iam trying to do the samething right now.Iam trying to set the field via business rule.can you tell me the syntax for both the client script and the business rule?

Thanks