
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2015 07:59 PM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2015 11:37 PM
Hi Andrew,
The following global UI script does the trick in Geneva
try {
getTopWindow().document.getElementById("4aeebcd20a0a0b9a00572ae3ad68b072").style.backgroundColor = 'red';
}
catch(e){
}
Thanks,
Berny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 12:20 AM
Hi Berny,
Its a great tweak. I was trying to use "Window.document" but it was unable to identify document object, but getTopWindow() method works fantastically.
Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2016 08:47 AM
Thanks swarnadeepnandy for taking the time to comment that this solution worked for you. I'm really glad it was helpful!
Just keep in mind to be cautious of future releases as this type of scripting could break if the html structure could change through release/patches of ServiceNow.
Thanks,
Berny

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2016 01:23 AM
Hi Berny,
getTopWindow() is working fine when the form is opened in a new window, but when it is opened inside the navigation pane iframe, it is notworking.
PFB the screenshot for the same
Any workaround for this?
Is it something that getTopWindow() not able to take the id as it is inside the iframe?
Thanks & Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2016 04:11 PM
Hi Swarnadeep,
Iframes are special (and to some extend evil) on sooo many ways
Here goes some links that may be helpful:
javascript - Accessing an element outside of iframe - Stack Overflow
How to get an element outside of iframe with javascript or jQuery? - Stack Overflow
javascript - Access elements of parent window from iframe - Stack Overflow
Thanks,
Berny