- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2020 05:56 AM
Hello,
I have a duration field called 'days'. I need to convert the number of days into hours and then set a separate integer field to that number. 1 day should = 8 hours. Example: The user enters 5 days and presses submit, the after insert business rule should set the integer field to 40.
(Please don't throw a bunch of links at me, I have looked everywhere)
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2020 06:26 AM
you mentioned days in duration type field ?
try now, tested with below code .
var gr = new GlideRecord('incident');
gr.get('f144d5002f849090f68d5ff62799b688');
var ab = gr.u_duration.getDisplayValue();
var op = ab.split(' ')[0];
var hr = parseInt(op*8);
gs.print(hr);
Edit:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2020 06:01 AM
sample code:
var ab = current.number_of_days;
var hr = parseInt(ab*8);
current.<fieldName> = hr;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2020 06:11 AM
That's not working, I'm not sure that you can multiply the entire duration field by 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2020 06:17 AM
I set the duration field to 10 days
Tried this to test your code:
var test = parseInt(current.days);
gs.addInfoMessage(test);
Got this result:
1970.0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2020 06:26 AM
you mentioned days in duration type field ?
try now, tested with below code .
var gr = new GlideRecord('incident');
gr.get('f144d5002f849090f68d5ff62799b688');
var ab = gr.u_duration.getDisplayValue();
var op = ab.split(' ')[0];
var hr = parseInt(op*8);
gs.print(hr);
Edit: