Tutorial: Event-Based Processing in Arc

Implement custom logic, send email notifications, or use your existing batch files by hooking into the events for your Arc connectors. This tutorial shows you how to trigger actions in events. As an example, you will execute a batch file after sending a file from the AS2 Connector.

Taking Control of Events

Arc enables you to take advantage of events through simple scripts. On the Events tab, click Insert Snippet in order to insert a code snippet that performs the action you want. Actions available in Arc include the following:

  • Executing batch files
  • Sending emails
  • Processing Excel spreadsheets
  • Processing XML files
  • File I/O
  • Database I/O

Arc includes a scripting engine that makes it easy to template documents and automate manual processes. In scripts, you can invoke the built-in operations or trigger other connectors.

ArcScript is the scripting language of Arc. You will find many familiar programming constructs in ArcScript, such as conditionals, loops, and flow control.

You will also find constructs from RSS feeds and XML. Attributes, items, and feeds provide the inputs and outputs to operations.

Triggering Batch Files from Events

The sysExecute operation is a powerful tool for executing programs and commands. To run a batch file when your event fires, click Insert Snippet -> Execute Batch File. The following code is inserted into the event script:

<!-- Execute Batch File -->
<arc:set attr="Name"       value="C:\\temp\\myfile.bat" />
<arc:set attr="Arguments"  value='"[FilePath]"' />
<arc:call op="sysExecute" />

The script passes the following input parameters to the sysExecute operation:

  • Name: The name of the command or program to execute. In this example, the value is a string representing the path to the batch file.
  • Arguments: The command-line arguments for the command or program. In this example, the value is the evaluation of the FilePath input to the AfterSend event, which is the name of the file that was sent. Use square brackets around an attribute name in order to get the attribute value.

All of an event's inputs are listed in the rsb:info block near the top of the script. Inputs include useful information available at that point in the data flow.

Below is the api:info block for the AfterSend event:

<!-- NOTE: Do not edit rsb:info -->
<arc:info title="After Send"     desc="This event is fired after sending a file.">
  <input name="PortId"           desc="The Id of the port that sent the file." />
  <input name="Direction"        desc="The direction of transaction." />
  <input name="Filename"         desc="The name of the file that was sent." />
  <input name="FilePath"         desc="The path of the file after sending." />
  <input name="IsSynchronous"    desc="The MDN delivery mode of the send message." />
  <input name="AS2MessageId"     desc="The AS2 Id of the send message containing the file." />
  <input name="MessageId"        desc="The Id of the send message containing the file." />
  <input name="ErrorMessage"     desc="If an error occurred, this will contain the error message." />
</arc:info>

See the Scripting chapter in the Arc help documentation for more information on processing event inputs, example scripts, and an ArcScript reference.



Ready to get started?

Use Arc's free 30-day trial to start building your own custom workflows today:

Download Now