Populate Duration field value to Duration field value

Tim77
Tera Contributor

Hi, we would like to populate a Duration field with another Duration field value using a BR.

The part that we need help with is how to populate a Duration field value to another Duration field.

//var duration = current.getValue('durationField');

//grSomething.setValue('durationField2', duration);


How can this be done?

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Hi Tim,

When working with duration type fields, it's best to use the dateNumericValue() function - though you can try to see if getValue works the same in this case.  If both of these duration fields are on the same table that the BR is running on, and it is running before insert/update, then your script would just be:

 

current.durationField2 = current.durationField.dateNumericValue();

 

If the 2 duration fields are on different tables, then you would need to include a GlideRecord to retrieve the record from the other table then either similarly update the duration field on that record using the value from the current table, or update the duration field on the current table from the value of the duration field in the GR retrieved record. 

View solution in original post

6 REPLIES 6

Community Alums
Not applicable

Hi @Brad Bowman , I am trying to do something similar. I have a duration field on the incident table called 'Total time worked' where I want to capture the sum of the time worked. Instead of using the 'Time worked' timer that extends from the task table, we want users to manually put the time in. We have the 'time worked' related list [task_time_worked] at the bottom of the form. Would I be able to use something like this to show the sum of the time worked?

Since you have a custom duration field that is being populated manually, the sum of the time worked will show on the incident form, correct?  Where else do you want to see this value?