I 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 thing 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. Let's see how I have done this.
Overall Solution Architecture
Let's consider a business process we would like to automate. This process is pretty common for large organizations like banks, insurance or logistics companies. All these organizations have to work with large number of customers who potentially can be dishonest. 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 are too many.
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 has 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.
Technical Solution for Dynamics CRM
As a basis for interaction with the customers, we may choose Microsoft Dynamics CRM 2011. This system fits the requirements of a wide interaction with the customers, no matter which communication technology they prefer. The system supports direct information storing via web service call. It is 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 scanned documents. The last thing is a support for workflow processes which allow 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 recognized 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.
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 recognize barcode and text from document on receiving of an e-mail in an e-mail queue.
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, then it could be useful for routing scanned documents to the 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 are going to print a barcode on an employee computer and it has 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.
Bulk Document Printing
The records from Dynamics CRM then 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.
The mail merge mechanism allows us to use not only letters printing, but also bulk e-mail sending. All we need in our solution is create a new organization mail merge template, which can be used for all bulk printing tasks by different members of a postal team.
The set of the records will be directed to Microsoft Word which provides a simple step by step wizard for printing. The good thing about this solution is that we can change individual letters during print preparation.
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 Sent.
The member of a postal team will go to printer and will print the ream.
Print Document Journey
The printed document then 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. Then, there is no need to print an address on the envelope.
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 a 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).
Unfortunately, such customization is not always possible. For example, HP’s equipment I worked with had no such capacity, but RICOH’s had.
All scanned document will be delivered to a Dynamics CRM message queue if it is configured properly. You can refer to my previous post about such configuration.
On receiving of a scanned document, we can provide text recognition logic in the form of a second Dynamics CRM plug-in.
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. Then to recognize 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 then could apply recognition algorithm which is based on a simple neural network.
During the PoC, I have found that ZXing is not recognizing barcodes if document scanned in resolution less than 200 dpi. It 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 of the existing monospace fonts. The important issue with barcode recognition is that if PDF has been produced by virtual printer, then the barcode is presented as a text not as picture. So, my plug-in will have to recognize this. It has been done by custom algorithm.
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 has 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. A full trust instead of CRM Online plug-in sandbox isolation is required.
The Result and Following Workflow
We're almost there. Text and signature is recognized. 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 then automatically place the information in a standard Account entity which is a final storage.
The scanned document can be placed in a security storage. For example, it could be done automatically for Microsoft SharePoint. In PoC, I have integrated the solution with Open Text Document Management system using web service call from the plug-in code.
Access from a Web Interface
For use case of an access from web interface, I have demonstrated sample web application based on Silverlight. I also wrote "How to integrate it with Dynamics CRM 2011 using web services" in the previous post.
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!
CodeProject