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

johansec
Tera Guru

I could be wrong but have you tried just setting it equal

 

gr.somethingDuration = current.durationField;

gr.update();

 

I believe i have done this before 

Tim77
Tera Contributor

Appreciate it, thank you!

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. 

This answer in combination with the one from johansec definitely solved it. Thanks!