Adobe Livecycle Workbench provides a great tool for executing BeanShell scripts.
BeanShells sripts allow executing a piece of code on the fly. The best part of BeanShell scripting is that it doesn’t have unnecessary syntactic sugar which complicates and increases the learning curve. Rather one can simply use his/her java skills and write down the code and run it on the fly on a LiveCycle running server.
This mostly comes handy when one wants to execute a code quickly on the server but wants to avoid creating a project in an IDE and going through all the hassles of collecting the dependent jars in class-path and thereafter instantiating ServiceClientFactory and providing server details to connect.
Since the script gets executes within VM, hence it doesn’t require the pre-requisites such as providing the dependent jars or server detail configurations.
The following example demonstrates a simple “Hello World” code written in BeanShell script and executed on the LiveCycle server.
I’ve written a cookbook recipe for invoking various User Manager APIs through BeanShell scripting which one can find at,
1. Connect the Workbench to a running LiveCycle server.
2. Create a new Application. Specify the name of the Application and click on Finish button.
3. Create a New Process under the Application.
4. Mention the Process name and click on Finish button.
5. A Process SwimLane will be opened on the right side. Drag the Activity Picker and attach it to the “Default Start Point”.
6. Once done, a “Define Activity” pod comes up. Enter the Activity name and search for “execute script” in the Find box.
Else, the Execute Script activity can also be found by navigating to “Foundation->Execute Script 1.0” under Service tab.
7. Once done there will be a new window opened on the left side with the name “executeService Operation”. Click on the button in the Input box.
This will open up a Text Area where the code to be executed can be written.
8. Enter the code with proper imports and click on OK button. Then click the Save button on the top left corner or press CTRL+S.
9. Goto the Applications tab in the left top corner. Right click on the relevant process and click on “Invoke”.
Click OK on the screen where it asks “Check in all files”. Click OK on the next screen where it notifies of “No Input Variables”.
10. Look into the server logs of the application server on which LiveCycle server is running. The output will be printed in the INFO level logs.
The above was a simple example to show the working of BeanShell script in LiveCycle through Workbench.
But in Enterprise world the script would be interacting with inputs from different processes and returning processed results to further joining processes.This can be achieved through patExecContext object which is explicitly available to the script.
An example can be found at,