For Duration field, how to show only days?

RatneshTSN
Giga Guru

For Duration field, how to show only days?

I have tried as per documentation:

https://docs.servicenow.com/bundle/kingston-application-development/page/script/general-scripting/co...

But its not showing

Its not working for days, for minutes its working

To show only days, how its achievable , can anyone point out...

Attribute set for minutes

find_real_file.png

 

 

Duration field converted to Minutes

find_real_file.png

Attribute set for days

find_real_file.png

 

 

But its not showing only days:

find_real_file.png

 

 

9 REPLIES 9

Mohammed_Iqbal
Tera Guru

Hello Ratnesh,

 

for show only days in duration field you need to hide min and sec. and we can achive this using script.

 

OnLoad client:

function onLoad() {
 
g_form.getElement('ni.u_community.calendar_durationdur_hour').style.display='none';
    g_form.getElement('ni.u_community.calendar_durationdur_sec').style.display='none';
    g_form.getElement('ni.u_community.calendar_durationdur_min').style.display='none';

//---inspacted element---> ni.u_community.calamder-duration_hour
}

and for getting element of the field you just inspect the field:

1>press F12

2>click on the arrow button

find_real_file.png

3>then hewer mouse on the field section you get the element name.

4>provide that name in your script like: ni.u_community.calamder-duration_hour.

 

HOPE THIS HELPS!!!! MARK CORRECT OR HELPFUL.


Regards,
Mohammed Iqbal

find_real_file.png
www.dxsherpa.com

For hour; its label still showing, & it has no ID or NAME to get it hide.

Any Idea?

 

find_real_file.png

Jace Benson
Mega Sage

So I think the attribute you're applying only removes parts of the input if the higher unit isn't accepted anymore, meaning, when you say max_unit=mintues it will no longer show days.

There isn't a min_unit attribute that I'm aware of, personally I'd open a HI ticket and ask.

You could just make a integer field and have that set a duration field else where in a business rule, kinda clunky but it would work.

I will raise with Hi-Portal to see if there is something like this.

Thanks for details.