Tuesday, September 24, 2013

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. (Lets use it with Document content type.)
  1. Create new content type and enable bar code through Information Management Policies.
  2. Add the content type to required libraries.
Step 1: Create new content type:
  1. Navigate to Site Settings >> Click on "Site Content Types"sharepoint 2010 barcode support
  2. Create New content type by clicking the link "Create"
  3. Give a Name to the content type (E.g. "Project Plan"). Specify the parent content type as "Document Content Type" sharepoint barcode documents
  4.  Enable bar code through Information Management Policies: From the content type settings page, Click on "Information Management Policies"sharepoint 2010 records management barcode
  5. Click on "Enable Bar code" check box, and click "OK" to save changes.sharepoint 2010 barcode support
 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.
  1. Go to your target libraries where you need bar code functionality.
  2. Navigate to library settings >> click on "Advanced Settings" >> Enable content types by clicking "Allow management of content types" to "Yes"sharepoint 2010 barcode feature
  3. Now, from the library settings, Click on "Add from existing site content types" link under "Content Types" section.
  4. Choose the content type we created at step 1 (In my case, it is: "Project Plan") and click "OK"
  5. Modify the default view of the document libraries to include Bar code columns.barcode in sharepoint 2010
  6. That's all! We are done! Create new document under the document library, See the bar codes in action!!barcode with sharepoint
Same steps applies to SharePoint 2007/ SharePoint 2010 and for SharePoint 2013.
sharepoint 2010 barcode value
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 bar code based on 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 = "http://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 event receiver to set custom barcode values. One draw back 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. http://www.aspose.com/sharepoint/barcode-component.aspx



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

4 comments :

  1. 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?

    ReplyDelete
    Replies
    1. 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.

      Delete
  2. 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

    ReplyDelete
  3. 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.

    ReplyDelete

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...