- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2022 10:18 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2022 12:24 PM - edited ‎10-31-2022 12:26 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2022 12:17 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2022 07:58 AM
Appreciate it, thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2022 12:24 PM - edited ‎10-31-2022 12:26 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2022 07:58 AM - edited ‎11-01-2022 07:58 AM
This answer in combination with the one from johansec definitely solved it. Thanks!