Enable Barcodes in SharePoint 2013 / 2010 / 2007
Bar codes are part of SharePoint Information Management Policies (IMP) feature. If you need bar codes for your document, here are the steps to enable bar codes on SharePoint document library.
Steps to enable bar code in SharePoint:
In SharePoint 2013 (In SharePoint 2007 / SharePoint 2010 too!) enabling barcode is a simple two-step process. (Let’s use it with document content type.)
- Create new content type and enable bar code through Information Management Policies.
- Add the content type to required libraries.
Step 1: Create new content type:
- Navigate to Site Settings >> Click on “Site Content Types”
- Create New content type by clicking the link “Create”
- Give a Name to the content type (E.g. “Project Plan”). Specify the parent content type as “Document Content Type”
- Enable bar code through Information Management Policies: From the content type settings page, Click on “Information Management Policies”
- Click on “Enable Bar code” check box, and click “OK” to save changes.
Step 2: Add the content to required libraries
We’ve our content type with bar code enabled ready! Next step is to associate our content types to libraries wherever required.
- Go to your target libraries where you need bar code functionality.
- Navigate to library settings >> click on “Advanced Settings” >> Enable content types by clicking “Allow management of content types” to “Yes”
- Now, from the library settings, click on the “Add from existing site content types” link under the “Content Types” section.
- Choose the content type we created at step 1 (In my case, it is: “Project Plan”) and click “OK”
- Modify the default view of the document libraries to include Bar code columns.
- That’s all! We are done! Create new document under the document library, See the bar codes in action!!
Same steps applies to SharePoint 2007/ SharePoint 2010 and for SharePoint 2013.
How to Set Custom value to SharePoint Bar Codes?
Well, But the problem is: SharePoint automatically generates unique 10 digit bar code value! we may not need it so in some cases, isn’t it? we want to set bar codes to specific value.
Alright, How do I set the bar code based on the file’s meta-data property? We can programmatically set Bar code values. Here is the sample code for SharePoint 2010 custom barcode generator.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using System.Drawing;
using Microsoft.Office.RecordsManagement.PolicyFeatures;
namespace SetBarCodeValue
{
class Program
{
static void Main(string[] args)
{
//Define the parameter values: Site collection URL
string siteURL = "https://sharepoint.crescent.com/sites/operations";
using(SPSite site=new SPSite(siteURL))
{
using (SPWeb web = site.RootWeb)
{
//Get a document library
SPList list = web.Lists["Design Documents"];
//Get an Item
SPListItem item = list.Items[0];
//Set Bar code value
Image img;
string barCodeValue = "900";
Barcode.ProvisionBarcodeWithValue(item, true, ref barCodeValue, out img);
Barcode.SetBarcodePreview(item);
item.Update();
//Print a message
Console.WriteLine("Bar code has been Updated!");
}
}
//Pause
Console.ReadLine();
}
}
}
You can place this code under the event receiver to set custom barcode values. One drawback with the OOTB SharePoint barcode integration is: it supports only digits!
SharePoint 2010 custom bar code generator:
There are 3rd party components to these limitations and provides enhanced functionalities. Aspose Barcode is one among them. https://www.aspose.com/sharepoint/barcode-component.aspx
Hello, i enabled the barcode…now i want to diasable the barcode…is this possible on 2013? Thanks Olli
Hello, Salaudeen
Thank you for sharing this article.
Your sharing point barcode generator is good. But now I only have C# barcode generator, I’m wonder whether I can generate barcode with C# barcode generator.
Best regards.
Hi Salaudeen, very interesting thank you. A detail you may want to add between steps 4 and 5 : define your barcode content type as “default content type”.
Isabelle
OK… so you have a barcode in a column. The feature to insert the barcode in the document was removed in SharePoint 2013. I am curious. What do you plan on using the above instructions for?
True! Because of low adoption, This feature was dropped in SharePoint 2013! But you can make a Open XML application that takes the server side barcode and injects into the Word document.