Can’t invoke action…

Thursday, July 24th, 2008

Sometimes the bain of my life.  It appears as a simple Metastorm BPM error and results in various messages logged in the event log and / or the eLog table.  This time the following event was logged in the application event log and it was looking like SQL Server was throwing a wobbly:

ErrorCode: ‘-2147467259′ Description: ‘Cannot create new connection because in manual or distributed transaction mode.’  Source: ‘Microsoft OLE DB Provider for SQL Server’  SQL State: ”  NativeErrorCode: ‘0,

Application Event Error

Sometimes the simple problems slow you down somewhat and it’s the time it takes searching for the information (that you know is out there) that takes the most of it.  Today was one of those days!

After searching on MSDN and other SQL related web sites I went back to the tried and tested Metastorm forum hosted by ProcessMapping and searched for the following string “distributed transaction mode”.

Lo and behold - one result - and the right one to boot!. 

The solution - run the script eWorkProcedures.sql found at:
C:\Program Files\Metastorm BPM\Engine\Database\SQL scripts\

It looks like I upgraded a test VM a while back but never quite completed the job.  I guess the moral of the story is check the Metastorm forums first, then look at other non-metastorm related sites.  It’s far easier that way!

Incorrect scripts being delivered to the web client

Thursday, March 20th, 2008

I’ve just wasted a few hours investigating an annoying bug - or possibly just a feature that we’re not aware of?

After making changes to a client side script and and trying to debug I was getting puzzled why changes I’d made in the designer were not being delivered to the client. 

At first I though this was just a IE “feature” so I cleared out the temporary files and cookies but this did not solve the problem, however it did solve another issue where the web client filters were not working correctly. Out of chance I ran the iisreset command and this allowed the correct version to be delivered, however after the next code change the client again received the older script.

Next under the microscope was IIS, this I assumed must be caching the files on initial delivery. After tweaking a few things it appeared this was in the clear to.  Back to the drawing board and running iisreset at every change.

After leaving the issue for a while I was inspecting the DOM of a delivered page and noticed the client script delivery mechanism:

<script type="text/JScript" 
        language="JScript" 
        src="eScript.ashx?AttachmentFile=ClientScript.js&amp;
             AttachmentOwner=map1&amp;
             AttachmentType=Procedure&amp;
             Service=Metastorm BPM Server&amp;

             Ver=29"></script>

Notice the “Ver=29″ tag?  Now this means that the web client is looking for a specific version of the client side script however if you had turned off versioning in the designer after initially publishing the procedure without really knowing what it does it means that no matter how many times you subsequently publish any newer scripts will not be delivered to the client.

I’m not sure if this is a bug or what Metastorm would call a feature but it’s certainly not obvious and surely the web client should then not attempt to retrieve versioned client scripts?  Earlier in the day I’d unchecked many of the check boxes under the Metastorm Designer’s publisher options section to remove the annoying pop ups that you get when developing.  Looks like it was one checkbox too many.  Roll on version 7.6…

Hope this saves you some time if you also get caught by this “feature”.

Grids Extensions

Friday, January 4th, 2008

I’ve been battling for a while with the web implementation of Grids in the web client. A couple of the features I would like to see included in a standard client include:

Standard methods that can be overridden to allow full control of what happens when a user clicks an individual row

Full control of cell content - i.e. let us embed HTML objects such as links & images etc…

A few years back we developed standard routines for expanding and shrinking the size of a grid which also managed the layout alterations that were then necessary. Although the users liked this additional control it was only really useful when designing forms that are constrained by size and contained many fields - it didn’t really make the actual operation of filling in the form any easier.

During the end of 2007 we have been developing for a client where extra control of the grid would have made the user experience far simpler so it was time to delve deeper into what goes on inside.  A few hours of investigation and we’ve produced some client-side JScript extensions that covers our needs.  I’m sure they won’t be suitable for all situations due to the additional complexity but when you really need to do something special hopefully these routines may be able to help.

Read the rest of this entry »

How to stop server-side code running when client-side validation fails for a command button

Wednesday, January 2nd, 2008

At times when developing UI functionality you will want to allow the user the ability to run a server side operation only if certain client side conditions are met.  This can range from tasks such as checking the information entered on a form is sensible and realistic such as checking for a valid postcode or more sophisticated checks such as ensuring all data entered in a grid is valid before carrying out a dependent e-mail operation.

Normally this type of validation is carried out when a form is submitted and we can easily trap these conditions. Return false from a validation script and it will stop the submission and therefore the server side code, however if you try to do something similar from a command button it’s not so simple.

The routine method is to simply not allow the user the option of pressing the command button prior to all conditions being met - these conditions being calculated by a hidden check box (or series) and having the button’s visibility set dependent on these.  i.e. When the conditions are okay the button is visible and  when the conditions are not okay the button is not visible.  Personally, I don’t really like this as it doesn’t give any opportunity for feeding back to the user to show why things may be wrong. From a design perspective it also creates a more cluttered view in the MBPM designer which can then lead to maintenance issues as a system grows.  Also, one last minor and avoidable niggle, it can leave a “hole” in the form’s design.

I think it would be more beneficial to allow the the client-side script to perform processing and validation before deciding if it should hand control on to the server for server-side processing. Luckily this is quite simple to achieve.

To do this follow these 2 steps:

  1. When the form loads associate a new event handler with the command button
  2. Create the new event handler

When the form loads ensure it calls the initialisation function:

   1: OnLoad=Init ()&Language=JScript

Create the initialisation function:

   1: function Init()
   2: {
   3:     //hook the command button to it's own event handler to allow
   4:     //validation before the server side operation is triggered
   5:     eworkData.FieldByName("btnCmd1").OnClick = btnCmd1Validate;
   6: }

Now create the event handler:

   1: function btnCmd1Validate()
   2: {
   3:     try
   4:     {
   5:         var RESULT = doComplexValidation();
   6: 
   7:         if (RESULT==true)
   8:         {
   9:             ButtonClick(document.getElementById("btnCmd1"));
  10:             alert("Server-side functionality processed");
  11:         }
  12:         else
  13:         {
  14:             alert("Server-side functionality NOT processed");
  15:         }
  16:     }
  17:     catch (ex)
  18:     {
  19:         alert (ex.message);
  20:     }
  21: }

Now when the the command button (btnCmd1) is clicked the new event handler is used.  This allows the function doComplexValidation() to be called which determines if we carry out further processing. If control should be passed back to the server then we call the Metastorm function ButtonClick() passing the command button element itself as the argument to invoke the server-side.

This gives the opportunity for full validation, additional opportunities for user feedback and the potential for taking pre-emptive corrective action should you need to.

Code highlighting test

Friday, December 14th, 2007

OK, before we start posting code examples I think we’d better check the code highlighting module:

  1. function hello_world(){ echo "hello world" }

If this works thanks are due to Dean Lee and his WordPress syntax highlighter.

Hello

Friday, December 14th, 2007

Welcome to our blog - we intend this to be a place we’re we document our techniques and the tips & tricks that we use when implementing Metastorm BPM solutions on our client sites.  Not all things will be relevant to day to day development and recommended for everyday use, however we’ll document what can be done and leave it to you to decide wether it should be done. Some of the benefits will outweigh the additional care & maintenance but this will need to be decided by you the developer on a case by case basis. 

Some of the first things we want to cover in the coming months include grid extensions, using rich text editors, building tag cloud functionality and more…

If nothing else it will be our bucket for tried and tested techniques that can be re-used where required…

We hope it’s useful to others too.

Cheers,

Paul.