Changing the URL type field display value
I was recently given a requirement to change the display text of the URL field in ServiceNow to be shorter and more user friendly. Here is how I implemented the solution. This takes into account the different ways you can view a record, either within the normal frame view, without the frame as well as the grid view (for list v3). I Hope you find this useful!
| 12345678910111213141516171819 | function onCondition() { g_form.setSectionDisplay('sl1_event', true); try { var doc; var iframe = top.document.getElementById('gsft_main'); //main iframe var listIframe = iframe ? iframe.contentWindow.document.querySelector('[name=gsft_list_form_pane]') : null; //split view iframe //listIframe is null if iframe is null (when open record outside of frame, ie. not within nav_to) OR can not be determined by the selector above (for when the record is opened in regular form view, no split view) if (listIframe == null) doc = iframe ? iframe.contentWindow.document : top.document; else doc = listIframe.contentWindow.document; //listIframe exists when record is opened in split view, set doc to listIframe.contentWindow.document var element = doc.getElementById('incident.u_sciencelogic_link_link'); if (element) element.innerHTML = 'Event Current Status'; //set text of URL } catch (ex) { console.log(ex); } } |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
http://helpfultechblog.com/servicenow/changing-the-url-type-field-display-value/?utm_source=rss&utm_medium=rss&utm_campaign=changing-the-url-type-field-display-value