Redirecting Workflow Approval E-mails
So you've built some workflows and all is well...until you get the phone call from the VP who is sitting on a beach in Hawaii. He calmly says, "Joe Smith just called me and says I need to approve his travel request today or he won't be able to travel to Timbuktu to visit with our #1 client. Go ahead and do whatever you have to do to approve Joe's travel request, because I won't have access to a computer for another two weeks."
Don't panic! Here's one way to redirect approval e-mails.
#1 - Create an Integration Component for webmanagementservice.asmx
Once you've deployed a workflow to your Workflow Server you'll notice a webmanagementservice.asmx in each of your virtual directories. We will use this to help us redirect e-mails.
Create a web service caller integration project.
Point the generator at any one of your WorkflowManagementService.asmx pages. This page will exist on any of your deployed workflows.
On the NameSpaces page check the box "Leave blank" under the Default URL Generation space.
Click through the rest of the wizard and compile. The generator will create a component for each of the web methods provided by the webmanagementservice.asmx. They are all very useful, but for now we'll just use the GetTask component.
#2 - Task Assignments and Dialog Workflow Components
In this example, lets pretend we use a dialog workflow component to gather data about a travel request. Joe filled out the web form and submitted it for approval. We looked up his manager via the GetManagerforUser component, so now we use a dialog workflow component to send an e-mail to the manager requesting approval.
To make things easy for us we assign a "task" to the manager, using his e-mail address. Doing this makes it easy to lookup all of that managers tasks, thus allowing us to do things like redirect an approval e-mail that was sent to him.
The dialog workflow component looks like this.
With the 1 Assignment being the e-mail address we got from the GetManagerforUser component (a process variable).
The other trick is to name the task your assigning to the manager with a meaningful name. In this example, we will name the task assigned by this component "Travel Request by [strUser]". The variable strUser comes from the GetCurrentUser component and defines for us who is submitting the request. Here is what it looks like.
#3 - Creating the Workflow Administration - Redirect Approval website
Create a new webforms project, not a workflow project.
Now import the integration component you created in step #1. Workflow solution makes this a snap, just hit the Import Components button and choose your new dll from the Custom Libraries Tab. You should see the new components.
Now that we have the components we need, we create the application. Here is the finished project.
The first Form component has a dropdown list of friendly names. These are all names of workflows we want to be able to redirect e-mail approvals for. In this example the dropdown contains "Travel Request" and "New Employee". I also gather the e-mail address of the manager ([strMngrEmail]) who currently has the task via a textbox component. Here is the form.
Next we add in a Lookup Data table. This component has two pages. On the first page we create a variable called strWebServiceURL and make its type Text.
On the second page we setup the URLs of each of the WorkflowManagementService.asmx pages we want to use. In other words, we tie each friendly name in our dropdown box to its corresponding WorkflowManagementService.asmx. Here is how the table looks.
Next we add in the GetTasks component from the Workflowmanagementservice namespace we created in step #1 and imported into our application. Assign it the following properties.
The [strWebServiceURL] variable was assigned by the lookup table and [strMngrEmail] was created by the web form.
The next web form gathers more information and is probably the most difficult to grasp. It looks simple, but its a bit more complicated underneath the hood.
The Task Name drop down list is populated by the Task Names of our dialog workflow components. This is why its important to name them so they make sense. In this example, the dropdown would have "Travel Request by Joe Smith". Here is what the dropdown list looks like.
Be careful here. Make sure the type is TaskAssignmentStructure. Ensure the Display Field is set to Task Name and the Items is set to [GetTasksResult], values : ()
The other thing we get on this form is the e-mail address of the person we want to redirect the approval e-mail to (strEmail]). This is just a simple textbox.
The final piece of the application is to send the e-mail. Use the send e-mail component to do this. Populate the to address with the process variable you get on the previous form ([strEmail]).
Give the e-mail a meaningful subject and then create the body of the message. Be sure to use the responses link, just like in the picture.
Now you have an easy way to redirect approval e-mails for any workflow application you build. To add more workflows just add them to the dropdown list on the first form and add them to the lookup table, republish the application and off you go.















Very Slick
We have had this issue with other workflow products. Looks like you fixed this before we got that far. Good deal!
Would you like to reply?
Login or Register to post your comment.