Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Barcodes, document flow and 100 points identification on MS Dynamics CRM 2011

, 20 Aug 2012 CC (ASA 3U)
Rate this:
Please Sign up or sign in to vote.
I have just finished Proof-of-Concept for one of our customers. The PoC was a demonstration of capabilities to automate paper document flow based on a custom solution for MS Dynamics CRM 2011. It involves barcodes generation, bulk document printing, scanning of paper documents and automatic recognit

I have just finished Proof-of-Concept for one of our customers. The PoC was a demonstration of capabilities to automate paper document flow based on a custom solution for MS Dynamics CRM 2011. It involves barcodes generation, bulk document printing, scanning of paper documents and automatic recognition of the barcodes and handwritten text within the documents. The solution uses QR Codes to identify the documents.

The most interesting is that we can produce some real documents (see photos inside!) and automate process using standard office equipment like printer and fast speed scanner. That was a big part of work and it have been successfully delivered within three weeks. Lets see how I have done this. 

Paper forms with barcodes

Overall solution architecture

Lets consider a business process we would like to automate. This process is pretty common for large organisations like banks, insurance or logistics companies. All this organisations have to work with large amount of customers who potentially can be not honest. That is the reason why each bank will ask you about all your personal details and could even ask for certified copies of documents. As we can see in this PoC, the certified copies is to much.

The company provides logistics services for persons all over Australia. So, we have the customers and some of them live in a rural area. Our customers can have an internet connection or can not have. So, some of them may use a company web site to apply for contract. The others will use a paper forms to apply. No matter how customer will apply for contract, we should have the same business process for electronic and paper applications. This documents will contain personal information and that is the reason to store it in a secured storage if we have legal permission to do so.

After customer have applied, the personal information should be validated against 100 points identification. Based on the validation results the company employee will offer a personified contract conditions for the customer. Later, the customer can call or email company to change the personal information or contract conditions.

Overall solution architecture

Technical solution for Dynamics CRM

As a basis for interaction with the customers we may choose Microsoft Dynamics CRM 2011. This system fits to the requirements of a wide interaction with the customers no matter which communication technology they will prefer. The system supports direct information storing via web service call. It it useful because we need to integrate it with the existing company web site. Additionally we can use a mechanism of e-mail queues which I have described in a previous post. This mechanism will be helpful for receiving a scanned documents. The last thing is a support for workflow processes which allows us to change status of an application after information verification.

On the other hand, usage of the product could have a potential limitations. For example in this PoC I have recognised documents using open source libraries with unsafe code. This means that the code must be executed with a full trust. But such scenario is not compatible with a sandbox isolation mode required for Dynamics CRM Online. So, this solution must only use an on-premises installation of the CRM.  

Technical solution based on MS Dynamics CRM 2011

The technical solution involves custom Silverlight controls for displaying barcodes and signatures. It is required because of standard functionality limitations in case you need to display a picture, a list of links or some rich contents. Also we need two custom plugins. The first will fill barcode information for newly created record. The second will recognise barcode and text from document on receiving of an e-mail in an e-mail queue.

The components of a technical solution

QR Codes generation

The barcodes could encode some metadata. The metadata in the PoC are used for document type and identifier storing. If the company uses barcodes on all paper forms than it could be useful for routing scanned documents to right location and for recognition purposes.

The QR code itself is a text. White space is a space character. Black space is a pseudo graphic character. The only issue when we would like to print a barcode is a font for printing. The font should be monospace without line spacing and with fixed line height. It potentially could be a problem if we going to print a barcode on a employee computer and it have no proper font. That is why the font should be included in a printing template.

There are a lot of libraries available for code generation. I suggest C# port of ZXing because of simple API and barcode recognition functionality. So, on creating of a record in a system we could generate a metadata and encode it as a QR code using custom Dynamics CRM plug-in. 

Control to display a barcode

Bulk document printing

The records from Dynamics CRM than could be printed using a standard mail merge functionality. A responsible employee will choose documents, for example in status Draft and will initiate a new mail merge.

Selecting records for printing

The mail merge mechanism allows us use not only letters printing, but also bulk e-mail sending. All we need in our solution is create a new organisation mail merge template, which can be used for all bulk printing tasks by different members of a postal team.

Create new mail merge

The set of the records will be directed to MS Word which provides simple step by step wizard for printing. The good thing about this solution is that we can change individual letters during print preparation.

Mail merge in MS Word

The result is presented in WYSWYG form. All we need is send this document set on printer. In this sample I will print welcome letters and personalized application forms for three customers. On document printing we will receive an activity creation dialog which allows us to run a workflow activity in Dynamics CRM. So, we could automatically change status of all printed documents to Printed or Sended.

Preview mail merge in MS Word

The member of a postal team will go to printer and will print the ream.

Log-in on printer

Bulk document printing

Print document journey

The printed document than can be folded and embedded in an envelop. In the PoC we had an envelop with transparent window. So, the address can be printed directly on top of the document. And no need to print an address on the envelops.

The post will deliver the document to a customer. The customer will fill, sign and post back the application form. The postal team will unpack all incoming messages and scan it using high speed printer.

Scanning to email

Almost all modern scanners or multifunctional devices can scan a document and send it to an e-mail. The company service desk team can help to set up a dedicated button on a device to scan the document to CRM’s message queue an e-mail in one click (sorry, tap).

Document scanning

Unfortunately, such customization is not always possible. For example HP’s equipment I worked with had no such capacity, but RICOH’s had.

Scanning document to e-mail

All scanned document will be delivered to a Dynamics CRM message queue if it is configured properly. You can refer to me previous post about such configuration.

On receiving of a scanned document we can provide text recognition logic in form of a second Dynamics CRM plug-in.

The result of the scanning in MS Dynamics CRM 2011 email queue

Automated recognition of a scanned document

The task of a document automatic recognition is not so trivial. The most important part here is an implementation. We need to parse a multipage PDF document. Than to recognise pages with the barcodes, extract document type from metadata and apply document grid according to document type. The main idea behind the document grid is that we should know exactly where to find a separate letter square. Only for a separate letter we than could apply recognition algorithm which based on a simple neural network.

During the PoC I have found that ZXing is not recognising barcodes if document scanned in resolution less than 200 dpi. It is really depends on the size of a QR code. That is why I have attended a research of a proper barcode size and font. I must admit that for production implementation of a system I would choose a custom font instead the existing monospace fonts. The important issue with barcode recognition is that if PDF have been produced by virtual printer than the barcode is presented as a text not as picture. So, my plug-in have to recognise this. It have been done by custom algorithm.

Testing different fonts for QR Code

When we have a type of the document it is time to apply a grid. We need to find a document corners, scale a grid and extract images of separate letters. The document corners have been marked with a black boxes of pseudo graphic characters. As a corner detection algorithm the SUSAN algorithm have been chosen. The implementation by AForge uses an unsafe C# code. That is why the proposed solution is not working in MS Dynamics CRM 2011 Online. It is required a full trust instead of CRM Online plug-in sandbox isolation.

The result of a corner detection algorythm

 

The result and following workflow

We almost there. Text and signature is recognised. The security around signature can be set up using different forms for security roles.

Now we can run a workflow to verify the document and than automatically place the information in a standard Account entity which is a final storage.

Extracted signature displayed in a custom Silverlight control

The scanned document can be placed in a security storage. For example it could be done automatically for MS SharePoint. In PoC I have integrated the solution with Open Text Document Management system using web service call from the plug-in code.

The result of the recognition

Access from a web interface

For use case of an access from web interface I have demonstrated sample web application based on Silverlight. How to integrate it with Dynamics CRM 2011 using web services I also wrote in the previous post.

Web interface for customers

This is it! If you have some questions or you would like to see that solution in Dynamics Marketplace do not hesitate to contact me. Thank you for reading!

License

This article, along with any associated source code and files, is licensed under The Creative Commons Attribution-Share Alike 3.0 Unported License

Share

About the Author

Pavel Korsukov
Architect
Australia Australia
No Biography provided

Comments and Discussions

 
QuestionBarcode Reader in CRM PinmemberMember 968700629-Dec-12 0:26 
AnswerRe: Barcode Reader in CRM PinmemberPavel Korsukov29-Dec-12 0:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 20 Aug 2012
Article Copyright 2012 by Pavel Korsukov
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid