Calculated hours based on time field in catalog item to auto populate duration hours on catalog form

PriyaRaj
Tera Contributor

Hi, 

 

I am having one field known as 'time' on my catalog item and once it is filled with a number then the field 'duration' on the same form should get autopopulated as time*8hrs(calculated).

 

Please let me know how I can achieve this using a catalog client script. This is urgent.

 

Thanks in advance!!!!

2 REPLIES 2

dgarad
Giga Sage

Hi @PriyaRaj 

 try below script and modify as per your requirement.

var durStart = new GlideDateTime(gs.nowDateTime());

var durEnd = new GlideDateTime(gs.nowDateTime());
gs.print(durStart);
durEnd.addSeconds(28800); 
gs.print(durEnd);

var duration = GlideDateTime.subtract(durStart, durEnd);
gs.print(duration.getDisplayValue());

 

If my answer finds you well, helpful, and related to the question asked. Please mark it as correct and helpful.

Thanks
dgarad

abirakundu23
Mega Sage

Hi @PriyaRaj ,

Please try below script.

abirakundu23_0-1715957152184.png

 

Please mark helpful & accept answer if it's worthy for you.