I have built a session to scan a document with the "Barcode" as a token. The session has a script to process the barcode as "a text key" to retrieve data from a database. It will then insert returned values to the fields of a template and assign a default document name with a returned value. When the barcode scanning fails to recognize the pattern due to overlapped lines or stains "on" the barcode, I will get a popup text field to collect the "text key" to retrieve the data from the backend. However, the document will be processed as an "identified document", so the fields are not filled (but the "document name" is filled with a returned value).
How can I force Quick Fields to assign a "DocumentClassName" to my template with script?
Here is the scenario:
Quick Fields version: 8.3
Language: C#
Code examples:
1.
string strBarcode = (string) e.Document.Tokens.GetTokenValue("BARCODE 1");
2.
if (string.IsNullOrEmpty(strBarcode))
{
// when barcode is not detected, get strBarcode from "this.TextboxValue" and then send to the database
}
3.
if (string.IsNullOrEmpty(e.Document.DocumentClassName))
{
//get a message when the template is not applied (Worked. Did get this message.)
e.API.ShowMessageBox("no documentname...");
//- the codes below indicated different attempts to "assign" a template. (Did not work.)
// e.Document.DocumentClassName("MYTEMPLATENAME");
// e.Document.Tokens.ChangeToken("Barcode 1", strBarcode);
// e.Document.DocumentClassName.Replace("", "MYTEMPLATENAME");
}
4.
no error message when the session ran.
the query returned a set of value but only the "document name" is filled.
5.
the file got scanned into the "unidentified documents" folder.
6.
Processing Summary:
1 page(s) processed.
0 identified document(s).
0 MYTEMPLATENAME (0 pages)
1 unidentified document(s).
0 error(s) occurred.
Pages Per Minute: 3
7.
a document with a "clear" barcode will result in a file with the right template format and all the fields are filled with returned values.
Thank you very much. Any help is appreciated.