Form Field Style not applying

xiaix
Tera Guru

Been here:   Defining Field Styles - ServiceNow Wiki

Been here:   Field styles are not getting applied

Still no go.   What's funny is in the supposed answer for Field styles are not getting applied   that Pradeep gave, his screenshot doesn't even show what it took.

Anyway... my situation:

find_real_file.png

find_real_file.png

As you see, no background-color red.

1 ACCEPTED SOLUTION

Yes yes, I agree with all that.   My apologies for trying to beat this dead horse.


I found a non-DOM solution:



g_form.flash('u_nonit', '#ad7', 0);


g_form.flash('u_nonit', '#ad7', 0);



(found here:   https://community.servicenow.com/thread/164290 )



btw...


Look forward to seeing you at K18!


View solution in original post

13 REPLIES 13

Hi David,



I always caution people when I see the use of DOM manipulation (document.getElementByID). This is at risk of not working in future releases. See if you can get it to work using g_form.getControl() instead.


I agree, Chuck, but the following doesn't work:


g_form.getControl('label.u_invoice_tracking.u_nonit').setAttribute('style', 'background-color: #ad7; color: #000; padding: 3px;');



I believe it's because getControl() is looking for field names, and what I need stylized is a field label.



Thoughts?


I only point it out because of the risk. If it works, it works. You just need to accept the risk of testing and maintaining it going forward.



ServiceNow is a powerful platform. The good thing is "you can do anything" and the bad thing is "you can do anything." We've had a lot of customer feedback recently that state "I wish I had stayed closer to OOB instead of making so many customizations."



Just because you CAN do a thing, doesn't mean you SHOULD do that thing. Try to offer your management/decision makers: options, costs, and risks so they can make informed decisions.


Yes yes, I agree with all that.   My apologies for trying to beat this dead horse.


I found a non-DOM solution:



g_form.flash('u_nonit', '#ad7', 0);


g_form.flash('u_nonit', '#ad7', 0);



(found here:   https://community.servicenow.com/thread/164290 )



btw...


Look forward to seeing you at K18!