How to add a field with Days:Hours:Minutes format

Sathwik1
Tera Expert

I need to add a field on a table..with format "Days:Hours:Minutes" it needs to fill as per the format...how to do it? can anyone suggest me

1 ACCEPTED SOLUTION

Hi,

updated below should work

function onLoad(){

var fieldName = 'u_downtime';
document.getElementById('ni.' + g_form.getTableName() + '.' + fieldName+ 'dur_sec').style.display = 'none';

}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Pratiksha Kalam
Kilo Sage

HEllo,

Refer,

https://community.servicenow.com/community?id=community_question&sys_id=dde243a1dbd8dbc01dcaf3231f96...

 

If answer is helpful please mark correct and helpful!
Thanks,
Pratiksha

asifnoor
Kilo Patron

Hi,

Kindly use the duration field type. Refer to this link for other types as well.

https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/reference-pages/ref...

Mark the comment as a correct answer and helpful if it helps. 

Ankur Bawiskar
Tera Patron
Tera Patron

@Sathwik 

you can use field type "Duration" but it would come with

Days:Hours:Minutes and Seconds also

No other option

So one way is to hide the seconds box for this field type

But that would require DOM manipulation which is not recommended

If you still require then create onLoad client script

Ensure Isolate Script field is set to false; This field is not on form but from list you can set it with false.

function onLoad(){

var fieldName = 'your field name here';

document.getElementById('ni.' + g_form.getTableName() + '.' + fieldName + 'dur_sec').style.display = 'none';

}

Output: It hides the seconds box

find_real_file.png

Note: users can still edit for the seconds from list

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

Thanks for the update, but client script is not working..

and I have set to false from the list[isolate script] eventhough its not working...

in place of fieldname I have used "coumnname[backend name]" and confirmed name is correct..

and used alert for verification..even alert was not came