NOTE: This will be done using the Modify Your Metadata activity in version 1.10 and later.
These activities are examples of grabbing a property off of a batch and applying it to the documents in that batch. These properties aren't metadata, but properties of the batch object we use.
For instructions on deploying an activity, refer to our Deploying Custom Activities Article.
NOTE: Running the below powershell will add a custom activity into your process designer under the category Custom Activities.
Set Batch ID Field in Documents
A batch id is the unique guid we assign to a batch. This will be a 32 character value.
Import-Module 'C:\Program Files\KnowledgeLake\Core\Modules\Capture.Core'
$role = Get-Role -Name 'Activity Processing'
# Set BatchID Document Metadata
############################################
# Batch ID will be set in documents
if((Get-ActivityDefinition -Name "Set Batch ID") -eq $null) {
Add-ActivityDefinition -Name 'Set Batch ID' -Category "Custom Activities" -ActivityType Action -ActivityScope Default -Version 1 -Active 1 -RoleId $role.Id -ScriptBlock {
$batch = $Context.batch
$bid = $batch.id
$Context.Batch | Get-Document | Set-DocumentMetadata -ClassKey 'Index' -Key 'Batch ID' -Value $bid
}
}
Step by Step
- The first thing this activity will do is grab the batch using $Context.batch
- Second, we will set a variable to the value of the property 'id' on the batch to a variable called $bid
- Lastly, we will apply the value of $bid to a Index field called Batch ID
Set Batch Name Field in Documents
A batch name is the friendly name of a batch you would see in monitor or index. This is
Import-Module 'C:\Program Files\KnowledgeLake\Core\Modules\Capture.Core'
$role = Get-Role -Name 'Activity Processing'
# Set BatchName Document Metadata
############################################
# Batchname will be set in documents
if((Get-ActivityDefinition -Name "Set Batchname") -eq $null) {
Add-ActivityDefinition -Name 'Set Batchname' -Category "Custom Activities" -ActivityType Action -ActivityScope Default -Version 1 -Active 1 -RoleId $role.Id -ScriptBlock {
$batch = $Context.batch
$bn = $batch.Name
$Context.Batch | Get-Document | Set-DocumentMetadata -ClassKey 'Index' -Key 'Batchname' -Value $bn
}
}
Step by Step
- The first thing this activity will do is grab the batch using $Context.batch
- Second, we will set a variable to the value of the property 'name' on the batch to a variable called $bn
- Lastly, we will apply the value of $bn to a Index field called Batch Name
NOTE: Other batch properties that can be gathered are listed below:
- Status - Current batch status
- Id - Unique identifier
- LockedUserToken - User the batch is locked to
- Locked - True or False whether the batch is currently locked
- Name - Friendly name of batch
- ActivityActive - True or False if Activity the batch is currently in is active
- WorkerLockTimeStamp - The time the worker last locked the batch
- UserLockTimeStamp - The time a user last locked the batch
Comments
0 comments
Please sign in to leave a comment.