How to approve/reject a workflow via blackberry?

  • 23 February 2009
  • 5 replies
  • 0 views

Badge +1

Hello,everyone, Is there any approaches to approve or reject a workflow via blackberry email? And how to resolve the security problems? When I use the blackberry email to open the web form to accept or reject a workflow, the blackberry display the error message: fail to login to the server. And anyone can help me? Thanks. 


5 replies

Badge +5

There are a couple of things to consider here.  First, it sounds like the user is opening a Web form on the device to action a worklist item (as opposed to approving/rejecting from an email on the device).  If this is the case, your code behind on the web page will need to impersonate the user who is logged in to the form.  I'm not a Blackberry expert but this concept is the same regardless if it is a Blackberry user or a normal PC user.  Basically when the user logs in to the form, the form must know who the current user is so it can impersonate that user, open his/her worklist, and then action that particular worklist item.  This doesn't necessarily have to be AD, as other custom Security Providers can be used (i.e. custom LDAP user store).  So, my question to you is how are you authenticating Blackberry users logging in to a web form that isn't connected to a K2 process? 

There is sample code available in the K2 documentation on how to do this, but it basically looks like this:


1. User logs in to website
2. Connect to K2 server
3. Impersonate the connection for the currently logged in user 
4. Load his/her worklist item (passing in the SN)
5. Enumerate through the worklist item's available actions, and if it matches what the user selects, execute that action


My lack of knowledge falls in the realm of authenticating Blackberry users.  I know that Windows Mobile devices can be part of a domain and can easily be authenticated, but perhaps someone else here can chime in on Blackberries.

The other option you have is to allow users to action his/her worklist items by replying to an email.  This will require creating a service that periodically checks an inbox or is triggered by a 'new email arrival event' on the server (the replied to email inbox) and parses through the email to check for a specfic string.  For example, if the user replies with [Approved], your service could find this string and then action a worklist item.  In this scenario the process serial number will also need to be passed in the email so the service can open the user's worklist item (which requires the SN).  This approach has its pitfalls.  For one, the user must conform to specified business policies since you are parsing text.  If a user makes a typo, you'll need to handle that in your service's code.  Also, Blackberry devices lock the original email text, so it forces the user to reply with properly formatted text as opposed to simply modifying the original email body's text and placing an 'X', or something similar, in the response.  For example, the original email body might have the available actions:


Approve[]
Decline[]
Rework[]


It would be nice if the user could simply reply to this email and place an 'X' between the action's brackets (Approve) and click send.  Newer models might support this, but from what I've found, the original text is locked so a user would have to manually type their response - increasing typo errors.

Badge +1

Many thanks to erice. As you said above, my most important problem is how to authenticate the user. The blackberry can't input any LDAP information( Our blackberry's model is a bit old, I know the newest model can input the LDAP identity when the user logging on).


The second solution(by replying to an email) is very difficult.But if there is not any other method, we must take it.


And anyone else has other solution?

Badge +13

Is there anything in the Blackberry SDK/API that would make approving K2 forms a bit more robust.

http://devsushi.com/2007/12/02/blackberry-jde-api-user-interface-field-reference/

http://www.blackberry.com/developers/downloads/jde/api.shtml

Badge +6

Hi,


I want to implemt your 2nd option which  "worklist items by replying to an email". Can you share some sample code or links to implement this feature?


Questions like


1. What kind of service we need to create to parse the email?


2. Once we have the required keywords, how to complete the task with respect to action so that it will go to next approver.


 


Please share any sample codes. 


 


 

Badge +5

urvijaykumar:


I do not have sample code for creating the service, but pseudocode might look something like this  (NOTE: this is just a sample and I could have missed a step or two):

if(timer has elapsed)
{
     CheckInbox()
}
CheckInbox()
{
     connect to exchange server
     check the inbox for the email address that is used in the K2 activities notifying users they have work
     if(inboxCount > 0)
     {
          ParseEmails()
     }
}
ParseEmails()
{
     check if email contains string placeholder //i.e. SN##192_23##
     if(contains string placeholder)
     {
          string SN = get SN out of string placeholder
          string Action = get action out of string placeholder  //i.e. Approved , APPROVED, etc.  depending on business rules
          connect to K2 workflow server
          impersonate connection //impersonate the person who replied to the email
          load user's work list item with SN
          action users work list item with Action string
          close connection to K2
     }
}

You will need to create a Windows Service project in Visual Studio and put some sort of Timer object in there that can be configured from an app.config file which will specify how frequently the service checks the inbox on the mail server.  Also, the emails that get sent out will  have to have some sort of structured format so the parser can get the Serial Number (SN).  Something along the lines of SN##<K2 Serial Number## or something so your code can search for SN## or some other uncommon string.  You'll also need a mechanism to query AD to get the user account that has the email address that is replying to the email so you can impersonate the call to K2 using that user account (i.e. the Destination User who is actioning the work).


As far as how to action (complete) the work list item so the process continues, there are very good code samples in the Developer Refernece in the K2 Documenation that gets installed with the product.

Reply