- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 05:52 AM
I want business elapsed time to be calculated entirely in hours not in days+hours.
How to create a new field which shows in hours by fetching data from OOB field ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 06:42 AM
Hi @Balakrishna_ABK ,
You can use the logic provided in the code below, you can achieve this using client script or business rule both.
Here's the client script logic, modify the field names accordingly
function onLoad(){
var duration = g_form.getValue('u_duration');
var durationArr = duration.split(' ');
var days = durationArr[0];
var hoursArr = durationArr[1].split(':');
var hours = hoursArr[0];
var totalHours = parseInt(days*24) + parseInt(hours);
alert(totalHours);
g_form.setValue('u_hours', totalHours);
}
If my answer has helped with your question, please mark it as correct and helpful
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 07:06 AM
Hello @Balakrishna_ABK ,
There is no need to create a new field if you want that duration in the hour's format. You can update existing field in the hours format also.
Go to Data Dictionary of that field, in the Advanced view of Dictionary entry, you will see the Attributes field. Enter "max_unit=hours" in the Attributes field and update.
Please refer following screenshot:
That field shows like this:
If my response helps to solve your issue. Kindly mark it as helpful & correct.
Thanks,
Pratiksha Panchal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 06:42 AM
Hi @Balakrishna_ABK ,
You can use the logic provided in the code below, you can achieve this using client script or business rule both.
Here's the client script logic, modify the field names accordingly
function onLoad(){
var duration = g_form.getValue('u_duration');
var durationArr = duration.split(' ');
var days = durationArr[0];
var hoursArr = durationArr[1].split(':');
var hours = hoursArr[0];
var totalHours = parseInt(days*24) + parseInt(hours);
alert(totalHours);
g_form.setValue('u_hours', totalHours);
}
If my answer has helped with your question, please mark it as correct and helpful
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 10:04 PM
Hi @Karan Chhabra6?/ @Pratiksha_45 , its working but everytime we need to load sla table to get value into custom field from actual OOB field. How to fetch value automatically without loading ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2023 07:06 AM
Hello @Balakrishna_ABK ,
There is no need to create a new field if you want that duration in the hour's format. You can update existing field in the hours format also.
Go to Data Dictionary of that field, in the Advanced view of Dictionary entry, you will see the Attributes field. Enter "max_unit=hours" in the Attributes field and update.
Please refer following screenshot:
That field shows like this:
If my response helps to solve your issue. Kindly mark it as helpful & correct.
Thanks,
Pratiksha Panchal