kamagra how much to take

Programmatically Changing a SharePoint Barcode

One of the limitations in the current version of SharePoint is auto-assignment of barcode information when a SPListItem is added to a container, contrary to consuming user input, such as a value from a generic reader to generate the barcode. Honestly, I find it a monster limitation since this situation is the most conventional implementation of Barcode ID strategies.

While by default it will work like this when using ListFormWebPart pages, it is feasible to override this default behavior from your own custom code to generate new barcodes, set to your ID, inclusive of preview and ID association for things like tooltips on hover over.

Firstly, there are some namespaces that people don’t work with very much that have to be used. These are Microsoft.Office.RecordsManagement.PolicyFeatures and Microsoft.Office.RecordsManagement.InformationPolicy. Once you have these references established, since the barcoding is inherent with imaging, it is helpful to set an Image global qualifier to the System.Image namespace as well ala Image=System.Drawing.Image.

Secondly, you actually have to employ the barcode fields themselves. Unfortunatly, the SPBuiltInFieldId enumeration doesn’t have a reference to any of the ID’s that are required which is kind of a bummer since we have to make SPField objects to represent those fields and turn off their readonly properties (SPField.ReadOnlyField). There are three fields that are a concern, the barcode value, the barcode image, and the barcode preview. Once you have those toggled off, the code is unsophisticated to get a new image and associated value. You simply have to use the Barcode.ProvisionBarcodeWithValue() and Barcode.SetBarcodePreview() methods, then call the SPListItem.Update() method, where the fieldValue variable is some arbitrary string representing the new ID.

  1. Image img;
  2. Barcode.ProvisionBarcodeWithValue(item, true, ref fieldValue, out img);
  3. Barcode.SetBarcodePreview(item);
  4. item.Update();

That’s it!

Share

4 Comments

  1. Parsa Aslani Far says:

    Hello
    Can you please give a sample code?

    I have this error.
    “Value cannot be null.
    Parameter name: spListItem ”

    where do you use this code? in Event Receiver or on Workflow?
    I use it in workflow with following Codes:

    Image img=Barcode.GetBarcodeImage(workflowProperties.Item);
    string fieldValue = “12345”;
    SPListItem Item=workflowProperties.Item;
    Item.Fields[“BarcodeImage”].ReadOnlyField = false;
    Item.Fields[“BarcodePreview”].ReadOnlyField = false;
    // Item.Fields[“BarcodeValue”].ReadOnlyField = false;
    Barcode.ProvisionBarcodeWithValue(workflowProperties.Item, true, ref fieldValue, out img);

    Barcode.SetBarcodePreview(workflowProperties.Item);
    Item.Update();

  2. Peter says:

    I have the same problem. I generated a new Item with spList.AddItem(). And set the ReadOnlyFields with

    if (spField.InternalName == “_dlc_BarcodeImage”) spField.ReadOnlyField = false;
    if (spField.InternalName == “_dlc_BarcodePreview”) spField.ReadOnlyField = false;
    if (spField.InternalName == “_dlc_BarcodeValue”) spField.ReadOnlyField = false;

    Any solution found.

    Greetings Peter

  3. sheraz says:

    Hello guys,

    Thanks for a wonderful post. I came across another product, Could you guys please suggest something about it.
    Many thanks
    sheraz

    HTML Post:

    Aspose.BarCode for SharePoint allows developers to insert barcode symbols in Microsoft SharePoint lists. Aspose.BarCode for SharePoint supports more than 40 of the most popular barcode symbologies including linear & 2D like Code128, Code39, Code93, EAN13, EAN14 (SSCC14), EAN8, UPCA, UPCE, BooklandEAN, Interleaved2of5, Standard2of5, MSI, Code11, Codabar, Postnet, Planet, SSCC18, PDF417, QR, DataMatrix & many more.  Aspose.BarCode for SharePoint is designed to work with MS SharePoint Server 2010.

  4. Monroe says:

    Barcode SharePoint Integration Guide
    http://www.keepautomation.com/how_to/sharepoint/

Trackbacks/Pingbacks

  1. Links (9/3/2009) « Steve Pietrek – Everything SharePoint - [...] Programmatically Changing a SharePoint Barcode [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>