Hide seconds on a duration field

mkader
Kilo Guru

Hello,

I am trying to find the best way to hide seconds from a duration field that we have. I am using something from another community post I found earlier. I was advised by a member on my team to modify the attributes on the field. How can I do that through an attribute?

This is what I have to currently hide the seconds and it works, but there is a temporarily glimpse at the seconds field while the page is loading:

function onLoad() {
    g_form.getElement('ni.pm_project.effortdur_sec').style.display='none';
}

Thanks!

1 ACCEPTED SOLUTION

Absolutely highly NOT recommended, for instance refer to the following official article:

https://hi.service-now.com/kb_view.do?sysparm_article=KB0692555

If I have answered your question, please mark my response as correct and helpful.

Thank you very much

Cheers
Alberto

View solution in original post

11 REPLIES 11

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

using DOM manipulation is highly not recommended in the platform.

Anyway, there is no way to remove this temporary effect, it's the way it works onLoad client script with DOM manipulation, which I wouldn't do at all.

Hope this clarify your question.

If I have answered your question, please mark my response as correct and helpful.

Thank you very much

Cheers
Alberto

@Alberto Consonni - So my client script is not recommended in ServiceNow?

Absolutely highly NOT recommended, for instance refer to the following official article:

https://hi.service-now.com/kb_view.do?sysparm_article=KB0692555

If I have answered your question, please mark my response as correct and helpful.

Thank you very much

Cheers
Alberto

@Alberto Consonni Thanks for sharing that with me. The support tickets resolution wrapped it in the addAfterPageLoadedEvent(). So if I do the following is this okay?

function onLoad() {

     addAfterPageLoadedEvent(function(){
       g_form.getElement('ni.pm_project.effortdur_sec').style.display='none'; 
     });

     //Your rest of the onload script
}