NOTE: This will be done using the Modify Your Metadata activity in version 1.10 and later.
Changing the metadata in your Title field may not seem like such a big deal, but this activity will show a very simple use case of populating a field that is both hard coded as well as using parameters to make that field and it's value configurable.
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.
Setting your Title Field
Below is the script to add an activity that will populate a set value into your Title field.
Import-Module 'C:\Program Files\KnowledgeLake\Core\Modules\Capture.Core'
$role = Get-Role -Name 'Activity Processing'
# Change Your Title
############################################
# $Title will be the value populated for the title field
if((Get-ActivityDefinition -Name "Change Your Title") -eq $null) {
Add-ActivityDefinition -Name 'Change Your Title' -Category "Custom Activities" -ActivityType Action -ActivityScope Default -Version 1 -Active 1 -RoleId $role.Id -ScriptBlock {
$Title = 'Insert Title Here'
$Context.Batch | Get-Document | Set-DocumentMetadata -ClassKey 'Index' -Key 'Title' -Value $Title
}
}
Step by Step
- Set a custom title to a variable of $Title
- The next line is setting the field Title to the value defined in step 1
Setting a Field and Value through the Process Designer
This script follows a similar formula to the one above, but will allow a user to not only use the Title field. They will be able to select a field as well as a value in the Process Designer Properties Panel using parameters:
Import-Module 'C:\Program Files\PaperStream\Core\Modules\Capture.Core'
$role = Get-Role -Name "Activity Processing"
$parameterList = New-Object System.Collections.Generic.List[Capture.Core.Data.Contracts.Configuration.ParameterBase];
$fieldName = New-Object Capture.Core.Data.Configuration.Parameters.StringParameter -ArgumentList '','$fieldNameInput','Field Name','Insert which field you would like populated.';
$fieldValue = New-Object Capture.Core.Data.Configuration.Parameters.StringParameter -ArgumentList '','$fieldValueInput','Field Value','Insert a field value to populate.';
$parameterList.Add($fieldName);
$parameterList.Add($fieldValue);
# Set Metadata
############################################
# This Activity Will let you Enter a Field and Value to Be Populated
if((Get-ActivityDefinition -Name "Change Your Title") -eq $null) {
Add-ActivityDefinition -Name "Change Your Title" -Category "Custom Activities" -ActivityType Action -ActivityScope Default -Version 1 -Active 1 -RoleId $role.Id -ParametersList $parameterList -ScriptBlock {
$Context.Batch | Get-Document | Set-DocumentMetadata -ClassKey 'Index' -Key $fieldNameInput -Value $fieldValueInput
}
}
Step by Step
- Our parameter list will consist of 2 string values that will be configured in Process Designer
- The $fieldName parameter's configured string will set a value called $fieldNameInput - This will be the field we are populating
- The $fieldValue parameter's configured string will set a value called $fieldValueInput - This will be the value we are populating
- The script will then look for a field equal to the value saved in $fieldNameInput and set the field to the value saved as $fieldValueInput
NOTE: For more information on parameters, class keys, and creating activities, refer to the Custom Activity Basics Article.
Installation
For instructions on deploying an activity, refer to our Deploying Custom Activities Article.
Configuration
The first example in this article doesn't have configuration. The second script however can be used by doing the following:
- Drag Change Your Title to the Process Designer Canvas
- A Property Panel should show up on the right hand side of your Process Designer
- Fill out Field Name with the field you would like to populate
- Fill out Field Value with the value you would like to insert into the field in step 3
- Click Save
Comments
0 comments
Please sign in to leave a comment.