Creating a Print UI Function

Rob Sestito
Mega Sage

Hello SN Comm,

I need some help in creating a Print Function for our HR Case Forms. Mostly for Employee Relations Cases, as they may sometimes need to print certain things from their Cases for legal/compliance groups for investigations.

I did find the following: https://community.servicenow.com/community?id=community_question&sys_id=cb5ecfeddb9cdbc01dcaf3231f961919

However, this has not worked for me when I attempt to point everything to the tables I need this to be one.

Overall I would like to follow the structure from the link I provided above. I would like to click on a UI Action based on the form I am in, bring me to a UI Page, that as another UI Action to click on, to allow me to (if possible), select from a number of fields to be printed.

Anyone able to help me out with this and or if someone else has done this and I am just unable to find it here on the Comm - to point me in the direction of it?

I greatly appreciate any help on this!

Thanks,

~Rob

1 ACCEPTED SOLUTION

Rob Sestito
Mega Sage

First, Thanks everyone providing options/suggestions with things. I reached out to SN directly because when I would try to use the system Print Friendly Version

find_real_file.png

 

Even that would cut off the additional tabs of information from our HR Case forms.

From ServiceNow:

It is part of PRB1153520 has been opened with our development team to correct the issue. The problem has been corrected in our upcoming Madrid release and we are currently targeting Kingston Patch 12 for the back-port.

Our instances are on Patch 9 for Kingston - so we will look to see if they can get this to Patch 12 and have it corrected. The workaround however, from the Tabs we have - I have to take Fulfillment Instructions and move it to the end of the list like so:

find_real_file.png

Originally, this tab was the first one, and we moved it to be the second one. But, workaround in order to be able to print everything is to move it to the end. Now everything shows up using the system print friendly function:

find_real_file.png

 

Again, Thanks everyone that helped with this. The system printing function will be just fine for us.

~Rob

 

View solution in original post

13 REPLIES 13

Morning Creative,

That either made a print screen come up right when I loaded the form without me clicking on any UI action(s) - Or, it would bring up a print screen, of only the section of the form I am on. If I scrolled down to the bottom of the form, and clicked on the UI again, then the print screen would only show that section I was looking at.

Thanks,

~Rob

balu3
Kilo Guru

Hi Rob,

 

If you're talking about the form view, why not use the ServiceNow Printer friendly version of the form.

It can be seen by going to a desired form record and then clicking the gear settings icon and then clinking on the printer icon.

find_real_file.png

 

If you want it as a UI Action, then write the code in the UI Action as follows

var url = gs.getProperty('glide.servlet.uri') + '/' + current.getLink(true) + '&sysparm_media=print';

action.setRedirectURL(url);

 

Thanks

Balu

 

Hello Balu,

I thought about that as well - however for some reason, it's not capturing all of the fields as I need them.. Here is an example - 

I have all these tabs within the Employee Relations HR Case form:

find_real_file.png

 

And when I click on the print friendly icon from settings (or create the UI Action to do the same function), I am missing all those tabs within the print - it just ends:

find_real_file.png

Thoughts as to why it would do that?

 

Thank you,

~Rob

Hi Rob,

Tabs are just a visual modification of the sections by displaying one of them and hiding the other. In case of printing, it should appear one below the other.

If not, then you are viewing another view, but the code is picking default view.

As per what I have noticed, everything in the form view should appear. There are quite some exceptions though.

  • In the form view, an image attachment added will have preview. There will be no preview in the print.
  • The attachment added will appear on top of the print as text, which might be unnecessary.

There is a way to adjust the printing view. Create a new view for the form, say 'printer'. Adjust the form according to the desired printing result. Then on the UI action, make changes as follows.

var url = gs.getProperty('glide.servlet.uri') + '/' + current.getLink(true) + '&sysparm_media=print&sysparm_view=printer';

action.setRedirectURL(url);

 

However, there might be some weird behavior as well.

The printer friendly version is also a type of form view, but without any major decorations. So it might take some time to load the data (especially work notes and comments). So after you click on the button, leave it for like 4 seconds before you proceed with the print. I do not know if everyone is facing this problem as well.

Also, the printer friendly view responds to the view that the form was in. Like for example, if you expand only 2 of the 4 work notes in the printer friendly form view and then click print, it'll appear exactly as what you have done in the print.

 

Thanks

Balu

 

Hey Balu,

Thanks for your reply!

The view is already set to Default for the HR Case Form I am testing this with. Therefore, I am unsure that I would need to create a new view for this.

I also waited a couple of minutes to see if the form to print was still trying to load however, unsuccessful. I also attempted to at least put myself on one of those tabs I showed you before in a screen shot. Thinking, if the form was viewing it, then the print function would take that. Still it did not.

Not sure why this isn't working correctly.

Thanks,

~Rob