Sample Scripts for Indexing Profiles
Below, sample scripts for extracting files using an indexing profile are listed. They can be modified and used to improve data extraction.
Creating a New Case
dim IxDataCaseHeader
dim CreateParams(0)
CreateParams(0) = "IndexData"
dim CreateParamsVar
CreateParamsVar = CreateParams
set IxDataCaseHeader = CreateThereforeObject(CreateParamsVar)
IxDataCaseHeader.SetCaseDef("TestCase")
IxDataCaseHeader.SetField "CaseHeaderData1", "My case header data 1"
IxDataCaseHeader.SetField "CaseHeaderData2", "My case header data 2"
IxDataCaseHeader.SetField "CaseNumberData1", 9001
nCaseNo = IxDataCaseHeader.SearchCase(true)
if nCaseNo > 0 then
SetCaseNo(nCaseNo)
elseif nCase = 0 then
nCreatedCaseNo = IxDataCaseHeader.CreateCase
SetCaseNo(nCreatedCaseNo)
elseif nCase = -1 then
ScriptError("Multiple cases found.")
end if
Different date format
If the date format used on the documents data is extracted from differs from the one the Therefore™ system is set to the ToDate function can be used. For example, if the documents contain dates with format DD.MM.YYYY but the system uses another format, the following function can be used to extract the dates:
ToDate(Extract("Invoice Date"), "DD.MM.YYYY")
Extract files from a folder
FilesToSave = "<path or relative path to the file>"
Extracting files defined in an XML file
FilesToSave = ExtractList ("FileName")
Handling eSignature documents based on status
Documents can be handled based on their signature status. Please note that not all providers have the same values for Signature.Status.
In this example, a keyword dictionary with the keywords 'Pending', 'Signed', and 'Declined' is defined. In the assignment field, 'keyword' is used.
keyword = "Pending"
if Signature.Status == "completed" then
keyword = "Signed"
elseif Signature.Status == "declined" then
keyword = "Declined"
end if
Importing Line Items
Line items can be extracted as a table using a script. The following script creates a table called myTable with two columns: Text and Number.
<myTable>
<Text> Text1 </Text>
<Number> 1 </Number>
</myTable>
<myTable>
<Text> Text2 </Text>
<Number> 2 </Number>
</myTable>
Use the following assignments:
ExtractListTable("Text,"MyTable")
ExtractListTable("Number","MyTable"
Namespaces
Extracting namespaces from XML files
dim namespaces(2)
namespaces(0) = "xmlns:udt='urn:un:unece:uncefact:data:standard:UnqualifiedDataType:15'"
namespaces(1) = "xmlns:ram='urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:12'"
namespaces(2) = "xmlns:rsm='urn:ferd:CrossIndustryDocument:invoice:1p0'"
SetNamespaces(namespaces)
Naming default namespaces
If a variable is defined using a script it can be used as assignment by simply entering the name of the variable.
namespaces(2) = "xmlns:def='urn:oasis:names:specification:ubl:schema:xsd:Invoice-2'"
Referring to namespaces during extraction
ExtractListXPath("/rsm:CrossIndustryDocument/rsm:HeaderExchangedDocument/ram:ID")
No file should be extracted