Metastorm BPM : Open file in browser


I’m working on a project at the moment that requires the metastorm application users to edit system generated .rtf files before they are merged with templates and posted/emailed/faxed out to customers.  The file should be opened via a Metastorm form, edited in Wordpad and saved back to the file server.

In Metastorm, I’ve made the applicable files available to the user from a metastorm grid which contains the files names and a hidden column for the UNC path of the .rtf itself, which we’ll use when the user selects a grid row (%myFilePath:=User.Input[x] etc).

Now its useful to point out that you can of course use word to open .rtf files in the browser by just calling the HTML window.open method and passing the location of the document, but word does add some additional information to the file when you save it, so in this case we’re using wordpad.  Wordpad is common across windows clients and its useful for client side editing of files.

In metatorm, I created a new client side script and added the following simple code:

function openWordpad(fileLocation){

var oShell = new ActiveXObject(“WScript.Shell”);

var command = “wordpad.exe ” + fileLocation;

oShell.Run(command);

}

This uses the local Shell API to run applications on the client machine via the windows script host ‘Shell’ Active X Object.  There are of course security risks to consider here and as browsers tend to be locked down a lot of the time, you’ll need to be sure your clients can run Active X controls in the browser (Active X Controls have the power to be malicious so bare this in mind).

Now I add a button to the form under my grid, ensure the button will execute a ‘Client Operation’ (see ‘button’ tab in button properties) and in the ‘Do This’ tab, add the following line:

OnClick=openWordpad(%myFilePath)&Language=JScript

This enables the user to select a document from the grid (which populates the %myFilePath variable), press the button and launch wordpad.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s