UI Script and DOM

Andrew Pishchul
Giga Expert

I'm trying to test a simple UI Script, but feel kind of lost - it's not working.. The idea is very simple - I want to make "Homepage" menu item under Self-Service red. I know the element id, but script is not working... I even added addLoadEvent function, no success... any ideas?

Screen Shot 2015-12-03 at 10.50.54 PM.png

1 ACCEPTED SOLUTION

bernyalvarado
Mega Sage

Hi Andrew,



The following global UI script does the trick in Geneva



try {


  getTopWindow().document.getElementById("4aeebcd20a0a0b9a00572ae3ad68b072").style.backgroundColor = 'red';


}


catch(e){


}



Thanks,


Berny


View solution in original post

23 REPLIES 23

Michael, Are you sure about this?   I'm using gel in a scoped ui context menu to print to PDF from a related list and it works fine.   Gel is basically the same thing as document.getElementById() .



Tom


I would verify with SN but there were several conversations previously about this.


Andrew Pishchul
Giga Expert

Well, it seems that DOM manipulation is not supported for the left navigation and top header areas in Geneva, but content area works.


Manjul Katare
ServiceNow Employee
ServiceNow Employee

Alright little bit in continuation of my previous post here!



What I see is whatever we write in UI script is included in "https://<instance-name>.service-now.com/scripts/js_includes_customer.js" file, which is only added in "Main Content". That means the scope of "js_includes_customer.js" is limited to content area and users would be only able to change the UI pages, whereas header & navigation areas are out of it.



Thanks,


Manjul


bernyalvarado
Mega Sage

Hi Andrew,



The following global UI script does the trick in Geneva



try {


  getTopWindow().document.getElementById("4aeebcd20a0a0b9a00572ae3ad68b072").style.backgroundColor = 'red';


}


catch(e){


}



Thanks,


Berny