Run your own script or program when a document arrives
Hand a new document to a program you wrote — a PowerShell script, a command-line tool, an API caller — the moment it's filed: register the program in the Configuration Manager, then a Content Capture trigger and a Run External Application action.
Before you begin
- Access to the Content Central server for the Configuration Manager
- A program or script on the server that accepts a file path (or document reference) as an argument and runs without a user present
When you're done, every new document of this type is handed to your program on the server, with the document passed in as an argument — the escape hatch for integrations that no built-in action covers.
- Trigger
- Content Capture › Content Captured in this Document TypeAny source
- Action
- Run External ApplicationExternal Application: the program registered in the Configuration Manager
- Rule
- "Filed → run our program", enabled
When this is the right tool — and when it isn't
Reach for this last. If the other system can watch a folder, export files to it; if it's an accounting package, use its connector. Run External Application is for the cases in between: posting to a web API, pushing a message to a chat tool, calling a line-of-business program that only has a command line.
The program runs on the Content Central server, as the service account, with no desktop. Anything that pops a window, prompts, or needs a mapped drive will hang or fail silently.
Register the program
On the server, open the Configuration Manager and go to External Applications.
Add an entry: a Name: (this is what the workflow action will list), the Location: of the executable, and the Argument List:. Use
$objectin the argument list where the document should be passed — Content Central substitutes the workflow's document at run time.
Apply. Details of the screen and its scoping: Configuration Manager: what lives where.
Test the command line by hand first, running as the service account, with a real file path in place of $object. Workflow won't tell you the script's error text.
Build the trigger
Go to Administration > Catalogs & Document Types, pick the Catalog and Document Type, click the Workflow tile, then Triggers > New Trigger.
Type:
Content CaptureandContent Captured in this Document Type. Trigger Name:New document filed. Save.
Build the action
Click Actions > New Action. Type:
Run External Application. Action Name:Run our program.
Choose the entry under External Application:. If the form says
There are no available external applications., the Configuration Manager step wasn't applied, or the entry is scoped to a different catalog or document type.
Click Save.
Wire the rule
Click Rules > New Rule. Rule Name:
Filed → run our program.
Add Trigger:
New document filed. Add Action:Run our program. Apply.
Test it
Have the program write a line to a log file of its own every time it runs, including the argument it received. File one test document.
Read that log on the server, and the document's View History.
What you should see: a new log line with the document reference, and the rule in the history. If the history shows the rule ran but the log is empty, the program failed to start: path, permissions of the service account, or an argument the program didn't accept.
Variations
| Want this instead | Change this |
|---|---|
| Run after approval rather than on filing | Trigger Approval Processes › Movement on Process, Approval by Final Member |
| Run nightly over a set of documents | A scheduled Content Query trigger — the program runs once per matching document |
| Pass field values, not just the document | Export a data file first with Export Data and have the program read it, or have the program query the Content Central API |
| Let a person run it from the document menu instead of workflow | The same External Applications entry can back a custom menu item |
| Convert the file format before handing it off | Action Format Convert earlier in the same rule |
