You can automatically create folders via script implementation. There are three events that are fired that you can use for
the creation of folders:
You can use script programming for those events to create and delete folders, and to reorder the documents in a batch. The
script programming can be tested in the
Project Builder
Documents window or in Test Validation. For example, you may use the
BeforeAutoFoldering event to skip foldering if a certain condition is fulfilled. You can use the
DoFoldering event to create folders and to place the documents in those folders.
The
DoFoldering event is fired once only. This means that if a batch or document is sent to
Tungsten Capture
-
Quality Control
because of an error, the
DoFoldering event is not fired again once the batch is resolved and sent for further processing.
To perform folder field extraction you can either use the above described events or the
Folder_BeforeExtract and the
<FolderFieldName>_BeforeExtract events that are executed after the foldering events.
For the folder field extraction events at first the event sequence of
BeforeExtract and
AfterExtract events for any folder in your batch is performed and its folder fields is performed. At last
this sequence is performed for the root folder and any configured root folder fields.
As a tutorial,
Tungsten Transformation Toolkit offers two sample projects installed with
Project Builder.
For the
DoFoldering event, the following script example shows how to create folders, move documents to
corresponding folders, and how to set a value for a folder field.
1: ' If folders exist, in the BeforeAutoFoldering event
2: ' they were deleted And All documents
3: ' copied back to the root folder.
4: ' Now they are being put into appropriate folders again,
5: ' each folder containing only documents
6: ' with the same ProcessID.
7: Private Sub Batch_DoFoldering(pXRootFolder As CASCADELib.CscXFolder)
8: Dim DocIndex As Long
9: Dim pXDoc As CscXDocument
10: Dim pFolder As CscXFolder
11: Dim ProcessID As String
12:
13: ' Loop over all documents in the root folder
14: For DocIndex = pXRootFolder.DocInfos.Count - 1 To 0 Step - 1
15:
16: ' Get the current document and its ProcessID
17: Set pXDoc = pXRootFolder.DocInfos(DocIndex).XDocument
18: ProcessID = pXDoc.Fields.ItemByName("ProcessID").Text
19:
20: ' Find a folder with this Process ID
21: Set pFolder = GetFolderByProcessID(pXRootFolder,ProcessID)
22:
23: ' If no such folder was found, create it and init
24: ' its ProcessID field
25: If pFolder Is Nothing Then
26: Set pFolder = New CscXFolder
27: pXRootFolder.Folders.Add(pFolder)
28: pFolder.Fields.ItemByName("ProcessID").Text = ProcessID
29: End If
30:
31: ' Move the document into the folder
32: pFolder.DocInfos.MoveInto(pXRootFolder.DocInfos(DocIndex), 0)
33: Next DocIndex
34: End Sub
35:
36: ' This is a helper function that searches the root folder
37: ' for a subfolder with
38: ' a certain value in its ProcessID field
39: Private Function GetFolderByProcessID(pRootFolder As CscXFolder, _
40: ProcessID As String) As CscXFolder
41: Dim FolderIndex As Long
42: Dim pXFolder As CscXFolder
43:
44: For FolderIndex = 0 To pRootFolder.Folders.Count - 1
45: Set pXFolder = pRootFolder.Folders(FolderIndex)
46: If pXFolder.Fields.ItemByName("ProcessID").Text = ProcessID Then
47: Set GetFolderByProcessID = pXFolder
48: Exit Function
49: End If
50: Next FolderIndex
51: Set GetFolderByProcessID = Nothing
52: End Function
This is what the script does:
Line 7: The
DoFoldering defines the event handler that is called. The
pXRootFolder object contains all documents. We assume that there are no folders present yet. Our goal
is to create one folder for each ProcessID we find in the ProcessID fields of the documents and move the respective documents into
that folder.
Line 14: Loop over all documents in the root folder.
Line 17: Get the current document.
Line 18: Get the ProcessID from the ProcessID field of the current document.
Line 21: Try to find a folder that contains the documents with the current ProcessID. At the beginning, no such folder
exists and the helper function returns nothing. The helper function is described later.
Line 26-27: If no such folder is found, we create one and add it to the root folder.
Line 28: For the newly created folder, save the ProcessID in the ProcessID folder field
Line 32: pFolder now is either the newly created folder or one that already existed. In both cases, it is the one that
matches the current ProcessID.
Line 39-52: This helper function checks all folders in the root folder to see if one of them matches the processID of
the current document. If so, it returns that folder, else it returns
Nothing.
After the
DoFoldering event, the batch now contains as many folders as different ProcessID values are present in the
documents.
Search resultsSearch tips
×
Search tips
The search returns topics that contain terms you enter. If you type more than one term, an OR is assumed, which returns topics where any of the terms are found. Enclose your search terms in quotes for exact-phrase matching.
The search also uses fuzzy matching to account for partial words (such as install and installs). The results appear in order of relevance, based on how many search terms occur per topic. Exact matches are highlighted.
To refine the search, you can use the following operators:
Type + in front of words that must be included in the search or - in front of words to exclude. (Example: user +shortcut –group finds shortcut and user shortcut, but not group or user group.)
Use * as a wildcard for missing characters. The wildcard can be used anywhere in a search term. (Example: inst* finds installation and instructions.)
Type title: at the beginning of the search phrase to look only for topic titles. (Example: title:configuration finds the topic titled “Changing the software configuration.”)
For multi-term searches, you can specify a priority for terms in your search. Follow the term with ^ and a positive number that indicates the weight given that term. A higher number indicates more weight. (Example: shortcut^10 group gives shortcut 10 times the weight as group.)
To use fuzzy searching to account for misspellings, follow the term with ~ and a positive number for the number of corrections to be made. (Example: port~1 matches fort, post, or potr, and other instances where one correction leads to a match.)
Note that operators cannot be used as search terms: + - * : ~ ^ ' "