Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to convert int field type to display hour format

Balakrishna_ABK
Tera Guru

Akhil7842_0-1706957369773.png

how to convert int field type to display hour format
currently Iam using format_glide_duration which is showing Day-time format

2 REPLIES 2

Anand Kumar P
Giga Patron

Hi @Balakrishna_ABK ,

 

https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/data-diction...

If above one not working Insted changing the field data type write script to change integer value to duration.

 

var catItem = current.cat_item.getRefRecord();

var durationSelected = parseInt(current.variables.estimated_duration);
if(current.variables.unit == 'Hours'){
var hourConversion = parseInt(durationSelected*60*60*1000);

catItem.durationField.setDateNumericValue(hourConversion);

catItem.update();

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

Hi @Anand Kumar P @ can we do it by changing attribute?