Printing out barcodes?

Benjamin Nuttin
Giga Expert

We would like the ability to print out asset receiving forms to send to our vendors. These forms would have data from the system, mostly in the form of text fields and the like, but they would also have barcodes. These would simply be a representation of the asset serial numbers in a special "barcode" typeface. Has anyone done this before? Any idea how we can implement this? Thanks!!

1 ACCEPTED SOLUTION

That's pretty cool! It worked well for me. I put the code39.js code in a UI Script named "code39" and then included it on a UI Page with the HTML:



<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:include_script src="code39.jsdbx"/>
<div id="externalbox" style="width:5in">
<div id="my_barcode" />
</div>
</j:jelly>


And then UI Page's Client Script is:



$("my_barcode").innerHTML=DrawCode39Barcode("123456789",1);


View solution in original post

22 REPLIES 22

Yes I have. I saw a barcode inventory/receiving system. It was implemented as a UI Page set up with a series of vertically stacked input fields on it. When the UI Page is initially displayed, JavaScript is used to place the cursor in the first input field. When the scanner was used to put text into the active field, an onChange script automatically advanced the cursor to the next blank input field. There was also an AJAX script that was triggered by the onChange that did a lookup to populate some information from the database in the space to the right of the input field.

This set up allowed the user to just keep scanning in data until the page was full. A submit button at the top and bottom of the page submitted the data. It was a pretty slick set up. The barcode scanner just types in the text contained in the barcode wherever the cursor is so it's pretty flexible.


Hi Eric,



We are going to use Barcod Scanner to add asset into ServiceNow.   Do you have sample codes that can share with US?


bbarnard
Kilo Contributor

Loading it as a UI Script worked great, thanks!


rashmi49
Kilo Explorer

Hi Eric,

Thank for the reply. I used g_list.getChecked in my UI action. It is returning the sysIDs of the selected records.

Now I made some alterations in my UI Action code but not sure how to get barcode printed for the selected records.

Please have a look at my code and suggest the way to achieve the same :-

function print()
{
var v = g_list.getChecked();
var a = new Array();
a = v.split(",");
for (var i=0; i < a.length; i++) {
alert(a);

test(a);
}

}

function test(var val[])*********This is throwing error--not sure how to pass parameter in array
{

for (var t=0; i < val.length; t++)
{
gs.setRedirect("barcode_generator.do?sysparm_encode=&sysparm_query=val
" + val.asset_tag);
gs.addInfoMessage("test");


}
}


For JavaScript functions, you don't put "var" for variables passed to them nor brackets. It should just be something like:
function test(sysIDs)