How to create a UI action and UI page to print a record

hamidouche
Kilo Expert

Hi all,

I am pretty new to SN. Here is what I wanted to do:

I want to create a button "print" that will launch the printing of the record.

I have already created the UI action.

My question is the following:

Where do I add the "window.print()" command? is it inside the UI action script or inside the UI page.

A specific answer with an example would be greatly appreciated!

Please do not refer me to SN documentation on UI actions or Pages, I already covered that!

ps. I want to implement the solution as stated above, not with the export to pdf or other options.

Thanks for your help

 

1 ACCEPTED SOLUTION

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

you have to use the window.print() command in the UI Page, below an example:

<input name="btnGo" id="btnGo" type="button" value="Print" onclick="window.print()"></input>

Hope this will fit your need.

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thanks you

Cheers
Alberto

 

 

View solution in original post

7 REPLIES 7

Yes correct, try to add this for example in the client script of the UI Page, it might work:

function onCancel() {
 var c = gel('cancelled');
 c.value = "true";
 GlideDialogWindow.get().destroy();
 return false;
}

Unfortunately, it's not working.

I'll look around if I can find other solutions.

Thanks

I hope you will find a solution!

Cheers

Alberto