Stop an activity and send e-mail on destination error

  • 13 December 2006
  • 4 replies
  • 1 view

Badge +3
Hi,

I've a process that use some custom code to get the destination user.
(I call a web service to get the destination user)

My question is how can I stop the current activity if the webservcie return an empty user (if the webservice don't find a user, it return an empty string) and send an e-mail to the originator of the process to allow him to redirect the current activity to another user.

Thanks

4 replies

Badge +11
I would...

1. Change the code behind the destination rule so that - if the web service returns an empty user, set the Originator as the Destination User.
2. In the SMTP Notification of the client event, I would build in some logic that - if the ActivityInstanceDestination.User.Name = Originator, send an email informing the originator to redirect the worklist item to an appropriate user. If the ActivityInstanceDestination.User <> Originator, send an email to the destination user informing him/her to action this worklist item.

I have not tested this but in principle it should work.

HTH,
Ockert
Badge +3
thanks, i will try ..
Badge +5
On a similar note, is there a way to send notification to an admin of the system an email if an error of any kind is encountered?
Badge +5

Hi Vinny,


What you can do is create a process level exception handler.  Note that you can also create activity level exception handlers in the exact same way.



  1. Right click on the canvas and select properties.
  2. Select exceptions from the left and then click "Edit Code".
  3. Copy and past the following

public void Main (ExceptionContext K2)
{
 ProcessInstance pi = K2.ProcessInstance;
 object err = K2.ExceptionObject;
    


 // check which type of exception and handle them specifically
 switch(K2.ContextType)
 {
  case(ContextType.ClientEvent):
                // handle client rule failure
                break;


  case(ContextType.DestinationRule):
                 // handle dest rule failure failed
                 break;

  case (ContextType.ServerEvent):
                 // handle server event failure
                 break;
 }
 // regardless of which type send admin an email.
 // Use System.Web.Mail and send an email.


}


please note that there are more ContextTypes than i've illustrated above.  Use intellisense to see all of them.  Also if you look in the help file you'll see another example of using the ExceptionContext class, search "ExceptionContext".


-mike




    
}


 

Reply