Using Folder Metadata in Activate with Custom Scripts and Expressions
9 min
Prerequisites
Before following this guide, ensure:
- Your environment has Shared Folders configured.
- These folders have been synchronized into Activate via the Folder Sync process.
Using Custom Scripts to Read/Write Folder Metadata
Sample Script
You can use a Script-type parameter in Activate Administrator to programmatically read and write metadata associated with folders. Here is a fully functional test script:
using System;
using Innovation.Activate;
using Innovation.Activate.Resources;
class Script : ScriptBase
{
public void main()
{
var folderResource = Evaluator.GetObject(@"=//Resources/Folders/\\MyFileShareScanTest\Test Folder 0001") as FolderResource;
if (folderResource is null) throw new Exception("Could not find folder");
LogAudit($"{folderResource}");
var originalAllMetadata = folderResource.FolderMetaData;
LogAudit($"Original Metadata is:\r\n{originalAllMetadata?.FormattedXml ?? "NULL"}");
var originalTestValue = Evaluator.GetString(folderResource, "=/FolderMetaData/testValue");
LogAudit($"Original Test Value is: {originalTestValue}");
LogAudit($"");
XmlValue x = new XmlValue("folder");
x.SetValue("testValue", "My Test Value");
folderResource.WriteFolderMetaData(x);
var newAllMetadata = folderResource.FolderMetaData;
LogAudit($"New Metadata is:\r\n{newAllMetadata.FormattedXml}");
var newTestValue = Evaluator.GetString(folderResource, "=/FolderMetaData/testValue");
LogAudit($"New Test Value is: {newTestValue}");
}
}
What This Script Does
- Finds a folder resource at a specific path inside Activate.
- Logs the current metadata (if any).
- Writes a new metadata element: <testValue>My Test Value</testValue>.
- Logs the updated metadata.
Output Example
Test Folder 0001
Original Metadata is:
NULL
Original Test Value is:
New Metadata is:
<?xml version="1.0" encoding="utf-16"?>
<folder id="7456" path="\\MyFileShareScanTest\Test Folder 0001" when="2025-05-22T04:37:51" site="[None]" server="MyFileShareScanTest">
<testValue>My Test Value</testValue>
</folder>
New Test Value is: My Test Value
-----------------------------------------
Script Complete: 0.2 secs
Referencing Folder Metadata in Activate Expressions
Activate Expression Syntax
Once metadata is written, you can access it in Activate using XPath-style expressions in conditions, parameters, or other scripts.
Example: Referencing the Metadata
=/FolderMetaData/testValue
This will resolve to:
My Test Value
Where You Can Use It
- Parameters – e.g., to auto-fill a field based on folder metadata
- Form Logic – e.g., hide/show elements conditionally
- Scripts – e.g., trigger actions or validations
Tips
- Ensure the metadata node you reference exists to avoid null values.
- You can validate or view metadata structure directly using the Audit Log output in scripts.
Summary
- Folder metadata enables powerful contextual workflows in Activate.
- You can read/write metadata using custom scripts.
- Use metadata values in Activate expressions with XPath syntax.