Using Scripts with
Indexing Profiles
www.therefore.net
© 2013 Therefore Corporation
ados.com
© 2013 Therefore Corporation
All rights reserved. No parts of this work may be reproduced in any form or by any means -
graphic, electronic, or mechanical, including photocopying, recording, taping, or information
storage and retrieval systems - without the written permission of the publisher.
Microsoft is either a registered trademark or trademark of Microsoft Corporation in the United
States and/or other countries.
Any other 3rd Party Products that are referred to in this document, are the property of, and
may be either trademarks and/or registered trademarks of the respective owners in the USA
and/or other countries. The publisher and the author make no claim to these trademarks.
While care has been taken in the preparation of this document, the publisher and the author
assume no responsibility for errors or omissions, or for damages resulting from the use of
information contained in this document.
VERSION: 2013 - 05
Log: 02
Added more sample scripts
Log:03
Not vallid anymore.
Log: 04
Corrected a script and removed tabs which were causing problems when copying.
Log: 05
Corrected a script and added info on doing assignments for Capture Client profiles where the
Category is set at runtime.
Contact: [email protected]
Table of Contents
1. Introduction .........................................................................................4
2. General Scripts .........................................................................................5
2.1 Fetching
......................................................................................................................................5
the correct date
2.2 Fetching
......................................................................................................................................5
the correct Money Format
2.3 Splitting
......................................................................................................................................6
a delimited list
2.4 Replacing
......................................................................................................................................6
charaters
2.5 Read
......................................................................................................................................6
a part of the text by using the mask
3. Microsoft® Office Profiles
.........................................................................................8
3.1 Restricting
......................................................................................................................................8
an indexing profile to a certain template
3.2 Extracting
......................................................................................................................................9
certain index data from the body of an e-mail
3.3 Extracting
......................................................................................................................................10
data from a PDF attachment of known structure
4. Therefore™ Capture
.........................................................................................11
Client Profiles
4.1 Setting
......................................................................................................................................11
a category using characters from barcode
4.2 Extracting
......................................................................................................................................12
index data from a part of a barcode
5. Therefore™ Document
.........................................................................................14
Loader Profiles
5.1 Importing
......................................................................................................................................14
line items
5.2 Defining
......................................................................................................................................15
the files that will be saved to Therefore™
6. Therefore™ Content
.........................................................................................17
Connector Profiles
6.1 Defining
......................................................................................................................................17
files that will be processed
6.2 Extracting
......................................................................................................................................17
index data from a folder structure
6.3 Extracting
......................................................................................................................................19
index data from a file name
© 2013 Therefore Corporation
Introduction
1. Introduction
From Therefore™ 2013 indexing profiles support the use of scripting (VBScript). The purpose of this
whitepaper is to document some of the most common things that can be achieved with scripting.
Please note that this document does not explain VBScript in depth and assumes that
you are familiar with it. For a complete documentation of VBScript please refer to the
Microsoft Download Center: http://www.microsoft.com/en-us/download/details.aspx?
id=2764
Please be aware that copying and pasting the scripts could cause formatting problems.
4 © 2013 Therefore Corporation
General Scripts
2. General Scripts
2.1 Fetching the correct date
Where the date format on the documents to be imported differs from the date on the operating
system, the ToDate function can be used. For example if the documents have a date with format
DD.MM.YYYY but the system uses another format then in the assignment you could use:
ToDate(Extract("Invoice Date"), "DD.MM.YYYY")
2.2 Fetching the correct Money Format
Where the money format on the documents to be imported differs from that on the operating system,
the ToFloat function can be used. For example if the documents have a money value with format
NNN,NNN.FF but the system uses another format then in the assignment you could use:
ToFloat(Extract("Invoice Amount"), "NNN,NNN.FF")
55
General Scripts
2.3 Splitting a delimited list
To split a list, for example separated by commas you can use the following script:
Dim SplitList
'split the list
SplitList = Split(Barcode.GetValue("Barcode1"), ",")
2.4 Replacing charaters
Sometimes it may be necessary to replace certain characters in extracted index data. For example:
Dim Replaced
Dim example
'replace characters
example ="example!"
Replaced = Replace(example, "!","?")
2.5 Read a part of the text by using the mask
Part of the the text, specified with the mask can be read when needed. For example, to extract
123456789 from EN:/FR:123456789 use following script:
ReadPart(Extract("Invoice Number"), "*:/*:?")
6 © 2013 Therefore Corporation
General Scripts
where "*" represents 'any text', the "?" represents the section to be extracted and "Invoice
Number" is the name of an extracted string.
77
Microsoft® Office Profiles
3. Microsoft® Office Profiles
3.1 Restricting an indexing profile to a certain template
A filter can be created that evaluates to true when the indexing profile is allowed to execute, or false
to prevent execution. To limit a profile to a specific Microsoft® Word Template called "Vacation
Request" use:
Template = "Vacation Request.dotx"
8 © 2013 Therefore Corporation
Microsoft® Office Profiles
3.2 Extracting certain index data from the body of an
e-mail
In the case of an e-mail from a web form for example, the structure of the form is know and so
extracting index data is possible based on predefined labels.
For example we have the following email body:
New Order
Company Name: Brightridge University
Company Address: 4 Highridge Road, Brightridge, 4568, River County
Order:
ITEM CODE PRICE/UNIT QTY TOTAL
T345 5.00 10 50.00
SUBTOTAL 50.00
Sales Tax 5.00
Total 55.00
The script to extract Company Name, Company Address and Amount would be:
Dim Name
Dim Address
Dim Amount
Dim AmountTemp
Function GetValFromBody (Body, Keyword)
Dim Pos
Dim posEnd
Dim Value
Pos = InStr(Body, Keyword)
If Pos > 0 Then
posEnd = InStr(Pos, Body, vbCrLf)
If posEnd > 0 Then
Value = Trim(Mid(Body, Pos + Len
(Keyword), posEnd - (Pos + Len(Keyword))))
End If
End If
GetValFromBody = Value
End Function
Company = GetValFromBody(Body, "Company Name:")
Address = GetValFromBody(Body, "Company Address:")
AmountTemp = GetValFromBody(Body, "Total")
Amount = ToFloat(AmountTemp, "NN.FF")
99
Microsoft® Office Profiles
3.3 Extracting data from a PDF attachment of known
structure
The first setp is to create a file profile with PDF extractor to extract text from the PDF using zonal OCR. In our
case this profile has the name "PDFOrders" (ID:243).
Then create an email profile with the following script.
Dim attachments
Dim attachmentNo
'set the attachment no. "0" is first, "1" is second etc.
attachmentNo = 0
'check if there are attachments. If there are then get the specified attachment
if AttachmentCount = 0 then
NotApplicable()
else
attachments = GetAttachments()
'Execute the defined profile. This can be the name or the number
'Using the name of the profile
ExecuteProfile "PDFOrders", attachments(attachmentNo)
'Using the ID of the profile no quotes are needed
'ExecuteProfile 243, attachments(attachmentNo)
end if
10 © 2013 Therefore Corporation
Therefore™ Capture Client Profiles
4. Therefore™ Capture Client Profiles
4.1 Setting a category using characters from barcode
To set the category using, for example, the 1st and 2nd character in a barcode called Barcode1 the
script would be:
Dim myBarcode
'Get the barcode value
myBarcode = Barcode.GetValue("Barcode1")
'Extract only the first two characters
Dim barcodeChars
barcodeChars = Mid(myBarcode, 1, 2)
'"Translate" the first 2 characters of the barcode to a category id
If barcodeChars = "EN" Then
SetCategory(1)
ElseIf barcodeChars = "DE" Then
SetCategory(2)
ElseIf barcodeChars = "FR" Then
SetCategory(3)
End If
11
11
Therefore™ Capture Client Profiles
You can get the category number in the Solution Designer under category properties.
You can also assign index values to these Categories. Right click on Categories Field header
and choose Add Assignments. Then choose the categories you would like to add assignments
for and then add assignments as per normal. The assignments will then be done at run-time.
4.2 Extracting index data from a part of a barcode
To extract, for example, position 1 to 9 of a barcode called "Barcode1" use the script:
Mid(GetValue("Barcode1"), 1, 9)
If this was a date then you could also use the ToDate function to make sure that it is converted
correctly. e.g.
ToDate(Mid(GetValue("Barcode1"),1,9),"DD/MM/YYYY")
Note: the Assignment will be marked in red, since the Barcode cannot be read at design time.
12 © 2013 Therefore Corporation
Therefore™ Capture Client Profiles
13
13
Therefore™ Document Loader Profiles
5. Therefore™ Document Loader Profiles
5.1 Importing line items
For importing line items from an XML file, scripting is needed in the assignments. As an example
consider the following simple table with two columns. The first has the name "Text" and the second
"Number"
Hallo 2
Welt
3
Consider also that the line item part of the XML file looks like this:
<myTable>
<Text> Hallo </Text>
<Number> 2 </Number>
</myTable>
<myTable>
<Text> Welt </Text>
</myTable>
<myTable>
<Number> 3 </Number>
</myTable>
The following scripts can be used:
ExtractListTable("Text,"MyTable")
ExtractListTable("Number,"MyTable")
14 © 2013 Therefore Corporation
Therefore™ Document Loader Profiles
5.2 Defining the files that will be saved to Therefore™
Please note that this is a mandatory script that needs to be specified for defining the
files that are going to be saved. For more details please refer to Administration
Manual.
Files that will be saved to Therefore™ need to be specified in the initialization script. This is done
using a script:
FilesToSave=ExtractList("FileName")
15
15
Therefore™ Document Loader Profiles
where FileName is the XML tag that defines the name of a file.
16 © 2013 Therefore Corporation
Therefore™ Content Connector Profiles
6. Therefore™ Content Connector Profiles
6.1 Defining files that will be processed
A filter can be created to exclude or include files. For example:
File.Name<>"Template.pdf", will not process any files with name "Template.pdf".
File.Extension="pdf", will only process PDF files.
6.2 Extracting index data from a folder structure
For extracting index data from a folder structure use following script:
File.GetPath(0)
17
17
Therefore™ Content Connector Profiles
where 0 defines the folder level and the level 0 is the parent folder of a file.
18 © 2013 Therefore Corporation
Therefore™ Content Connector Profiles
6.3 Extracting index data from a file name
Form extracting index data from a file name following scripts can be used:
Mid(File.Name, 1, 4), extracts first four characters of the file name
ToDate(Mid(File.Name, 5, 8), "DDMMYYYY"), extracts the string that starts at position 5 and
has a length of 8 characters; once the string is extracted a conversion for the date field is used
as it defers from the OS format of the date.
19
19