Printer Friendly Version truncating fields

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2016 04:07 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2016 04:33 AM
Well, I found where the code is, but I don't think there's anything in there I can change to expand those fields to show all the data:
h t t p s://YOURINSTANCE.service-now.com/scripts/js_includes_navpage.jsx:
function printList(maxRows) {
var mainWin = getMainWindow();
if (mainWin && mainWin.CustomEvent.fire("print", maxRows) === false)
return false;
var veryLargeNumber = "999999999";
var print = true;
var features = "resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=yes,location=no";
var href = "";
var frame = top.gsft_main;
if (!frame)
frame = top;
if (frame.document.getElementById("printURL") != null) {
href = frame.document.getElementById("printURL").value;
href = printListURLDecode(href);
}
if (!href) {
if (frame.document.getElementById("sysparm_total_rows") != null) {
var mRows = parseInt(maxRows);
if (mRows < 1)
mRows = 5000;
var totalrows = frame.document.getElementById("sysparm_total_rows").value;
if (parseInt(totalrows) > parseInt(mRows))
print = confirm(getMessage("Printing large lists may affect system performance. Continue?"));
}
var formTest;
var f = 0;
var form;
while ((formTest = frame.document.forms[f++])) {
if (formTest.id == 'sys_personalize_ajax') {
form = formTest;
break;
}
}
if (!form)
form = frame.document.forms['sys_personalize'];
if (form && form.sysparm_referring_url) {
href = form.sysparm_referring_url.value;
if (href.indexOf("?sys_id=-1") != -1 && !href.startsWith('sys_report_template')) {
alert(getMessage("Please save the current form before printing."));
return false;
}
if (isMSIE) {
var isFormPage = frame.document.getElementById("isFormPage");
if (isFormPage != null && isFormPage.value == "true")
href = href.replace(/javascript%3A/gi, "_javascript_%3A");
}
href = printListURLDecode(href);
} else
href = document.getElementById("gsft_main").contentWindow.location.href;
}
if( href.indexOf("?") <0 )
href += "?";
else
href += "&";
href = href.replace("partial_page=", "syshint_unimportant=");
href = href.replace("sysparm_media=", "syshint_unimportant=");
href += "sysparm_stack=no&sysparm_force_row_count=" + veryLargeNumber + "&sysparm_media=print";
if (print) {
if (href != null && href != "") {
win = window.open(href, "Printer_friendly_format", features);
win.focus();
} else {
alert("Nothing to print");
}
}
}
function printListURLDecode(href) {
href = href.replace(/@99@/g, "&");
href = href.replace(/@88@/g, "@99@");
href = href.replace(/@77@/g, "@88@");
href = href.replace(/@66@/g, "@77@");
return href;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 11:47 AM
We ran into this problem with the short description field. Filed a ticket with HI but were told:
After carefully considering the severity and frequency of the issue, as well as the cost and risk of attempting a fix, a decision has been made not to address this issue in any current or future releases.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 12:42 PM
Thank you, niamccash, for posting your received HI response. Such a shame to have pointed out an obvious flaw, it be in their control and abilities to fix, yet they're flat out going to ignore it.
I would expect that response from Micro$oft, not ServiceNow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2019 08:57 AM
Found myself in a similar problem. Here's what I came up with.
If you only need to modify one or two field(s) - Add a Field Style.
- Go to System UI -> Field Style and click new.
- Select your table and field and add a style:
width:300px;
If you want to apply style to all of the fields, the process get a bit more involved but is still rather simple.
The basic plan is to apply a style sheet to the "print view" by using a UI macro and Formatter. I've also added a UI Action on my form to open the print friendly view.
- Create a Style Sheet. go to Content Management -> Style Sheets and click New.
- Give it a name and make sure "Local Style Sheet" is selected.
- Add the Style you need and Save. For me, I added:
(If you use the inspector tool in your browser, you can see the class of the field element is "disabled").disabled {width:300px !important; }
- Copy the sys_id of your new Style Sheet record.
- Next, we need a UI Macro to reference the Style Sheet. Go to System UI -> UI Macros and click New.
- Give it a name (like: print_view_style) and record the name you used, this will be required later. (If this is for a custom application, make sure your scope is set to the correct Application)
- Add the following inside the <j:jelly> tag and Save:
<link href="<SYS_ID FOR YOUR STYLE SHEET>.cssdbx?" rel="stylesheet" type="text/css"/>
- (Optional) If you want to have any style modification (or other HTML added) only appear on the print view, you can add a conditional test (checking for &sysparm_media=print in the URL). Here is the complete result:
<?xml version="1.0" encoding="utf-8" ?> <j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null"> <j2:if test="${sysparm_media=='print'}"> <link href="<SYS_ID OF YOUR STYLE SHEET>.cssdbx?" rel="stylesheet" type="text/css"/> </j2:if> </j:jelly>
- Now to pull it all together we need a UI Formatter to call the UI Macro. Go to System UI -> Formatters and click New.
- Give the Formatter a name that you will remember, this is what will appear in the Form Layout configuration.
- In the Formatter field, enter the name of your UI Macro suffixed with .xml. In this example it would be print_view_style.xml.
- Choose the appropriate table for the formatter to be used on and save. (Again, if this is for a custom application, be conscience of the scope you are in when you are creating all of these records)
- Finally, use the Form Layout configuration to add the new Formatter to the top of your Selected slushbucket.
Here is an example of the UI Action I use:
Client = Checked
Form button = Checked
Onclick = printView()
Script:
function printView() {
var sysparm_table = g_form.getTableName();
var sysparm_sys_id = g_form.getUniqueValue().toString();
var a='https://<YOUR INSTANCE>.service-now.com/';
var view = 'Print_PO_View'; //Optional if you have a specific view you want
g_navigation.openPopup(a + sysparm_table + '.do?sys_id=' + sysparm_sys_id + '&sysparm_record_rows=1&sysparm_view=' + view + '&sysparm_record_target=' + sysparm_table + '&sysparm_record_list=ORDERBYnumber&sysparm_record_row=1&sysparm_stack=no&sysparm_force_row_count=999999999&sysparm_media=print');
}
Hope that helps!