- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2015 09:35 PM
For some reason the current built in functionality doesn't allow you show the XML of an item through a list view.
It only give the option via the form view. Its also worth mentioning that the built in 'Show XML' button isn't a UI action
CURRENT:
Show XML: form view
HOW:
To Show the XML for a desired record in list view create a UI action as follows.
all that is really needed is
OnClick: xmlView(g_list.tableName,g_sysId);
RESULT:
Show XML: list view
The XML shown will relate to the item that what 'right clicked' on the list. the solution should work on most if not all items in all tables, I haven't test this.
This Idea is SO simple that it begs the question, why wasn't it done earlier or out of the box?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2015 09:43 PM
If you wanted a reference to the actual code that Service Now use to show the xml, see below
function popupOpen(url, name, pWidth, pHeight, features, snapToLastMousePosition) {
popupOpenFocus (url, name, pWidth, pHeight, features, snapToLastMousePosition, true);
}
function popupOpenFocus(url, name, pWidth, pHeight, features, snapToLastMousePosition, closeOnLoseFocus) {
popupClose();
if (url.indexOf("?") != -1)
url += "&";
else
url += "?";
url += "sysparm_domain_restore=false";
var domain = gel("sysparm_domain");
if (domain)
url += "&sysparm_domain=" + domain.value;
if (url.indexOf("sysparm_nameofstack") == -1)
url += "&sysparm_stack=no";
if (snapToLastMousePosition) {
if (lastMouseX - pWidth < 0) {
lastMouseX = pWidth;
}
if (lastMouseY + pHeight > screen.height) {
lastMouseY -= (lastMouseY + pHeight + 50) - screen.height;
}
lastMouseX -= pWidth;
lastMouseY += 10;
features += ",screenX=" + lastMouseX + ",left=" + lastMouseX + ",screenY=" + lastMouseY + ",top=" + lastMouseY;
}
if (closeOnLoseFocus) {
popupCurrent = window.open(url, name, features, false);
if (!popupCurrent) {
alert('Please disable your popup blocker to use this feature');
return null;
} else {
popupCurrent.focus();
popupCurrent.opener = window.self;
return popupCurrent;
}
} else {
popupCurrent = null;
var win = window.open(url, name, features, false);
if (win) {
win.focus();
win.opener = window.self;
}
return win;
}
}
function xmlView(ref, id) {
var mytable = ref.split('.')[0];
var myfield = ref.substring(mytable.length + 1);
var w = 700;
var h = 500;
var url = new GlideURL(mytable + ".do");
url.addParam("sys_id", id);
url.addParam("sys_target", myfield);
url.addParam("XML", "");
popupOpen(url.getURL(), "xmlview", w, h, "width="+w+",height="+h+",toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollbars=1");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2015 09:43 PM
If you wanted a reference to the actual code that Service Now use to show the xml, see below
function popupOpen(url, name, pWidth, pHeight, features, snapToLastMousePosition) {
popupOpenFocus (url, name, pWidth, pHeight, features, snapToLastMousePosition, true);
}
function popupOpenFocus(url, name, pWidth, pHeight, features, snapToLastMousePosition, closeOnLoseFocus) {
popupClose();
if (url.indexOf("?") != -1)
url += "&";
else
url += "?";
url += "sysparm_domain_restore=false";
var domain = gel("sysparm_domain");
if (domain)
url += "&sysparm_domain=" + domain.value;
if (url.indexOf("sysparm_nameofstack") == -1)
url += "&sysparm_stack=no";
if (snapToLastMousePosition) {
if (lastMouseX - pWidth < 0) {
lastMouseX = pWidth;
}
if (lastMouseY + pHeight > screen.height) {
lastMouseY -= (lastMouseY + pHeight + 50) - screen.height;
}
lastMouseX -= pWidth;
lastMouseY += 10;
features += ",screenX=" + lastMouseX + ",left=" + lastMouseX + ",screenY=" + lastMouseY + ",top=" + lastMouseY;
}
if (closeOnLoseFocus) {
popupCurrent = window.open(url, name, features, false);
if (!popupCurrent) {
alert('Please disable your popup blocker to use this feature');
return null;
} else {
popupCurrent.focus();
popupCurrent.opener = window.self;
return popupCurrent;
}
} else {
popupCurrent = null;
var win = window.open(url, name, features, false);
if (win) {
win.focus();
win.opener = window.self;
}
return win;
}
}
function xmlView(ref, id) {
var mytable = ref.split('.')[0];
var myfield = ref.substring(mytable.length + 1);
var w = 700;
var h = 500;
var url = new GlideURL(mytable + ".do");
url.addParam("sys_id", id);
url.addParam("sys_target", myfield);
url.addParam("XML", "");
popupOpen(url.getURL(), "xmlview", w, h, "width="+w+",height="+h+",toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollbars=1");
}