Keyform StudioHelpOpen Keyform Studio

Training Guide: Scripts

This guide shows you how to create Workflow, Unity Form and WorkView scripts from a plain-English description, check the C# they produce, and put them into OnBase Studio. Allow about an hour, plus time in your OnBase Test system. You don't need to write C#, but you do need rights to create Unity Scripts in OnBase Studio for Chapter 8.

Chapter 1: What Unity Scripts are

Unity Scripts are small C# programs that OnBase runs at a set moment: when a document reaches a Workflow queue, when someone presses a button on a Unity Form, or when a WorkView action runs. Keyform Studio writes them from steps you choose or describe.

Script typeRuns whenWorks onTypical uses
WorkflowA Workflow action or rule runs itA document's keywordsCheck required keywords, clean up values, add a note, decide a rule's true or false result
Unity FormSomeone triggers a custom action on a Unity FormThe form's fieldsFill fields from a database lookup, stamp a date, check required fields
WorkViewA WorkView action runs itA WorkView object's attributesSet a status when a condition is met, stamp a review date, check required attributes

Every script is a list of steps, run in order from top to bottom. Each step is one job, such as "Check required keywords" or "Set Status to Needs Review when Risk Score is over 70".

Chapter 2: Tour of the Scripts tab

The Scripts tab has your scripts and the step list on the left, the script you're working on in the middle, and its C# code on the right.

AreaWhat's there
Unity ScriptsYour saved scripts, with their type and number of steps. New script starts another.
Add a stepThe steps available for the current script type. Select one to add it at the end.
Script settingsScript type (Workflow, Unity Form, WorkView), name, where names come from, what happens on an error, and logging
Describe what the script should doThe AI assistant box. Draft steps turns your description into steps.
StepsEach step as a card: its number, a one-line summary, its settings, and ↑, ↓ and Delete
CodeThe C# file, its problems and warnings, the review checkbox and Copy C#

The training connection includes three sample scripts, one of each type. If you don't see them, add them from Settings → Connections → Training → Add the sample scripts.

Chapter 3: Create a Workflow script with the assistant

You'll create a script that checks new invoices and flags large ones for manager approval.

Set up the script

  1. Select New script. It starts as a Workflow script.
  2. Name it Invoice Intake Check. The class name under the settings updates to InvoiceIntakeCheck.
  3. In Keywords from Document Type, choose AP - Invoice.
  4. Leave If something goes wrong as Stop the action and show the error, and keep logging on.

Describe it

Type this into Describe what the script should do, one instruction per sentence:

Make sure Vendor Name, Invoice Number and Invoice Amount are filled in. Trim and uppercase Vendor Name. Add a note saying "Checked by workflow: {Vendor Name} invoice {Invoice Number}". If Invoice Amount is greater than 10000, return true.

Select Draft steps. The assistant adds four steps and reports Drafted 4 steps.

Check the draft

  1. Read each step card. Under each one, From your description shows the sentence it came from.
  2. Read any amber notes under the draft summary, such as a step that needs a value you didn't give.
  3. Read any sentence listed as Couldn't turn this into a step, and rephrase it like the examples under What it understands.

Writing descriptions that work

If you draft again, the new steps replace the existing ones; the button asks you to confirm first.

Chapter 4: Add and edit steps yourself

You can build a whole script from the Add a step list, or adjust what the assistant drafted.

  1. In Add a step, select Set a keyword. A new step card appears at the end.
  2. Choose Due Date in Keyword to set, and Today's date in New value.
  3. Use ↑ to move it above the comparison step, so the comparison stays last.
  4. On step 1, select PO Number among the keyword chips to add it to the required list. The number on each chip is its order.

A step with a missing setting gets a red border, and the Code panel lists it as a problem.

The step catalogue

StepWhat it doesWorkflowUnity FormWorkView
Check requiredFails the rule (Workflow) or stops with a "Please complete" message if any listed value is blankYesYesYes
Compare a keywordSets the rule's true or false resultYesNoNo
Set a valueSets text (with placeholders), today's date, or a session propertyYesYesYes
Set a value when a condition is metTests one value, then sets anotherYesYesYes
Clean up a valueTrims, collapses spaces, changes letter caseYesYesYes
Combine valuesJoins several values with a separator into anotherYesYesYes
Fill from a databaseRuns a SQL query with values from the script and copies columns backYesYesYes
Send to a web servicePosts chosen values as JSON to a URLYesYesYes
Add a noteAdds a note of a chosen Note Type, with placeholdersYesNoNo
Save for laterStores a keyword in a session property for later Workflow actionsYesNoNo

When several Workflow steps set the rule result, only the last one counts; the checks warn you about it.

Chapter 5: Read the generated C#

The Code panel updates with every change. You don't need to write C#, but you should be able to find each part and confirm it does what the steps say.

PartWhereWhat to check
Header commentTopThe script name, type, Document Type, and What it does: one line per step in plain English
using linesBelow the headerLibraries the script needs. A web service step adds System.Net.Http; a database step adds System.Data.Odbc.
Class linepublic class InvoiceIntakeCheck : IWorkflowScriptThe class name and the interface OnBase calls
Entry methodOnWorkflowScriptExecute(...)Where OnBase starts the script; it picks up the document being processed
StepsInside try { ... }, each under // Step 1: ...One block per step card, in the same order
Error handlingcatch (Exception ex)Writes the error to the Diagnostics Console, then stops or carries on as you chose
HelpersBottomShared code for reading and setting keywords, filling placeholders, and logging

Before you copy

  1. Clear every Problem listed above the code.
  2. Read every Warning and decide. The "rule result" warning is expected in Chapter 3's script, because the required check and the comparison both set it and you want the comparison to decide.
  3. Tick I've read this script and will test it in a Test environment. Copy C# becomes available.
  4. Select Copy C#. If the browser blocks it, the code is selected; press Ctrl+C.

Any change to the script clears the tick, so the copied code always matches what you reviewed.

Chapter 6: Unity Form scripts

A Unity Form script runs when someone triggers a custom action on a Unity Form, such as a Look up vendor button. You'll build one that fills the vendor's name and email from a database.

  1. Select New script, then Unity Form under Script type.
  2. Name it Vendor Lookup.
  3. In Unity Form field IDs, paste the IDs of the form's fields, separated by commas: VendorNumber, VendorName, VendorEmail, RequestDate, Notes. Copy the real IDs from the Unity Forms designer; they're case-sensitive.
  4. Describe it:
Make sure VendorNumber is filled in. Look up VendorName and VendorEmail from the database using VendorNumber. Set RequestDate to today.
  1. Select Draft steps. Three steps appear, with a note on the database step.
  2. Open the Fill fields from a database step and finish it:
    1. Connection string setting: the name of the configuration item that holds the ODBC connection string, usually set up by your OnBase administrator. The default is ODBCConnectionString.
    2. SQL query: replace your_table with the real table, for example SELECT vendor_name, vendor_email FROM vendors WHERE vendor_number = ?. Each ? is filled by a field you pick, in order.
    3. Columns to copy: one line per column, column = FieldID, for example vendor_name = VendorName.
  3. Clear the checks, review, and copy the C#.

In a Unity Form script, a failed required check stops the action with a message such as "Please complete: VendorNumber". Workflow-only steps, such as adding a note, aren't offered; the assistant tells you if you ask for one.

Chapter 7: WorkView scripts

A WorkView script runs from a WorkView action and changes the attributes of the object it runs on. You'll build one that reviews a new vendor.

  1. Select New script, then WorkView under Script type.
  2. Name it Vendor Review.
  3. In WorkView application and class, choose Vendor Management / Vendor. Its attributes appear in the step pickers.
  4. Describe it:
Make sure Vendor Name, Tax ID and Email are filled in. If Risk Score is greater than 70, set Status to "Needs Review". Set Reviewed Date to today.
  1. Select Draft steps and check the three steps. You can write attribute names with spaces (Risk Score) or without (RiskScore); the assistant matches either.
  2. Open the Set an attribute when a condition is met step: the test is RiskScore is greater than 70, the attribute to set is Status, and the new value is Needs Review.
  3. Clear the checks, review and copy the C#.

The WorkView entry-point names aren't publicly documented for every OnBase version. The note under the code says so: compile it in a Test system first and use Chapter 9 if OnBase Studio reports a name it doesn't know.

Chapter 8: Put a script into OnBase Studio

OnBase Studio is where Unity Scripts are stored, compiled and attached. Menu names vary by version, so follow your version's OnBase Studio documentation alongside these steps, in a Test system.

  1. Open OnBase Studio and connect to your Test repository.
  2. Create a new Unity Script, named the same as the class, for example InvoiceIntakeCheck.
  3. Replace the starter code Studio creates with the code you copied from Keyform Studio.
  4. Add references the header comment asks for: System.Net.Http for a web service step, System.Data for a database step.
  5. Compile, or build, the script. If it fails, go to Chapter 9.
  6. Save and check the script into the repository.
  7. Attach it where it should run:
Script typeAttach it to
WorkflowA Workflow action or rule that runs a Unity Script, in the queue where it should run
Unity FormA custom action on the Unity Form, for example on a button
WorkViewA WorkView action of the Execute Unity Script kind, on the class
  1. Run it on a test document, form or object, then open the Diagnostics Console to read its log lines, which start with the class name in brackets.

Chapter 9: Fix compile errors

Most compile errors from generated scripts come from one cause: a name in the Unity API that differs in your OnBase version. Fix the name once in Keyform Studio and every script uses the fix.

Error in OnBase StudioWhere to fix it
The type or namespace IWorkViewScript (or another interface) could not be foundSettings → Script API names → Interface for that script type
The script doesn't implement a member, or the method isn't calledMethod for that script type
WorkViewEventArgs (or another arguments type) could not be foundEvent arguments type
args.Object (or args.FormInstance) doesn't existObject the script works on
System.Net.Http or OdbcConnection not foundAdd the reference in OnBase Studio (Chapter 8, step 4)
A member such as AllFields or CreateFormModifier doesn't existA helper in the generated code; send the error to your Keyform Studio administrator so the template can be corrected

Correcting an API name

  1. Find the correct name in your Hyland Unity API documentation, or in a working script your team already has.
  2. Open Settings → Script API names.
  3. Change the field for that script type. It saves as you type.
  4. Back on the Scripts tab, review the code again and copy it.
  5. Paste it into OnBase Studio and compile again.

Reset to defaults on the same page puts the original names back.

Chapter 10: Practice exercises

Do one script of each type on your own, then check it against its list.

Exercise 1: Workflow, claim triage

On CLM - First Notice of Loss: make sure Policy Number and Claimant Name are filled in; uppercase Policy Number; if Estimated Amount is greater than 25000, return true.

Exercise 2: Unity Form, request defaults

With the field IDs RequestedBy, RequestDate, Department, Notes: set RequestDate to today; if Department is "IT", set Notes to "Route to the IT team".

Exercise 3: WorkView, contract expiry

On Vendor Management / Contract: make sure Contract Number and End Date are filled in; if Contract Value is greater than 50000, set Owner to "Legal".

When you're done