Label Printing:- End user details from a Request or Incident

jonathangilbert
Kilo Sage

Hi All,

I have only seen a handful of questions regarding this, but no real resolutions. What I would like assistance with is when a end users come to the Service Desk to leave their equipment, I would like the technician to be able to print a label directly from the request or incident form ( using a "UI Action" button and populate the fields automatically that would contain the following:-

Caller Name

Request/Incident Number

Barcode (to take technician to request/incident)

Short Description

Date (when printed)

I have installed the barcode generator from share.servicenow, but that doesnt give me what I am after

Many Thanks

16 REPLIES 16

HI Varun,



I have a similar requirement, somehow for me I am not able to fit in my information that is required to be printed in the DYMO printer. Any guidance around how we can do configuration changes i the script to accommodate the label printing needs.


Regards


Nitin


Hello Varun, could you please respond with some more information about this, we are quite a few that have that exact requirement.




Thanks


Niklas


Hey Niklas,



What do you want to do?



i have done this, i can help you..





Yogish


Hey Yogesh, I want to via a UI action be able to print out a label for assets with:



- a unique barcode for each asset (they are scanned with usb-scanners)


- Product name/number (for example Lenovo Thinkpad XX)


- Serial number





Regards


Niklas


Hey Niklas,




I think this will help you.




Step 1) Create a UI action on the asset table, name it anything.



Select OnClick in the UI Action and call this function : printBenchLabel()



UI Action script:



function printBenchLabel() {


  var sysid   = g_form.getUniqueValue();



  var features = "resizable=yes,scrollbars=yes,status=yes,toolbar=no,menubar=yes,location=no";



  var href = "setprintlabel.do?sysparm_stack=no&sysparm_view=print&sysparm_media=print&sysparm_id=" + sysid;



  win = window.open(href, "Printer_friendly_format", features);


  win.focus();


}






You have to create a ui page for the print preview, i have done this using a jelly script.



Step 2: Create a UI Page Name: setprintlabel



Note: My script is written for sc_task table, you will have to change it below and make it to assets table.


Script:


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">



<j:set var="jvar_ctask_id" value="${sysparm_ctask}" />


                         


<div style="height: 20px" class="print_hide" align="right">


<button type="submit" onclick="javascript: window.top.print();"><img src="images/printer.gifx"></img>


<span>Click to Print</span>


</button>


</div>


                         


<g:evaluate var="sysparm_id">  


  var sysparm_id = RP.getParameterValue("sysparm_id");


  sysparm_id;  


</g:evaluate>      


 


<g:evaluate var="jvar_record" object="true" jelly="true">  


  var gr = new GlideRecord("sc_task");  


  gr.get(jelly.sysparm_id);  


  gr;  


</g:evaluate>


                         


<table style="width:35% height:20%">


            <tr><td></td><td><b>Assigned To </b></td><td>: ${jvar_record.getDisplayValue('assigned_to')}</td>   </tr>                          


            <tr><td></td><td><b>Short Description</b></td> <td>: ${jvar_record.getDisplayValue('short_description')}</td> </tr>


              <tr><td></td><td><b> CI</b></td><td>: ${jvar_record.getDisplayValue('cmdb_ci')}</td> </tr>


              <tr><td></td><td><b> Asset Tag</b></td><td>: ${jvar_record.getDisplayValue('asset_tag')}</td> </tr>


</table>  




<style>    


    td{font-size: 15px;}


</style>



</j:jelly>





PS: Your feedback (Like, Helpful or Correct) helps community





Thanks


Yogish Dafedar