business elapsed time (task_sla) in Hours.

Balakrishna_ABK
Tera Guru

Akhil7842_1-1690030098012.png

 

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 ?

2 ACCEPTED SOLUTIONS

Karan Chhabra6
Mega Sage
Mega Sage

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);
}

 

KaranChhabra6_0-1690033297278.png

 

KaranChhabra6_1-1690033323374.png

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks!

 

 

View solution in original post

Pratiksha_45
Kilo Sage

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:

Pratiksha_45_0-1690034560599.png

That field shows like this:

Pratiksha_45_1-1690034655844.png

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. 
Thanks,
Pratiksha Panchal

 

View solution in original post

3 REPLIES 3

Karan Chhabra6
Mega Sage
Mega Sage

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);
}

 

KaranChhabra6_0-1690033297278.png

 

KaranChhabra6_1-1690033323374.png

 

If my answer has helped with your question, please mark it as correct and helpful

 

Thanks!

 

 

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 ?

Pratiksha_45
Kilo Sage

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:

Pratiksha_45_0-1690034560599.png

That field shows like this:

Pratiksha_45_1-1690034655844.png

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. 
Thanks,
Pratiksha Panchal