Home
TeamSite
Approve and Reject via Email using Workflow
sunil_j
Hi,
I want to provide the feature of Approving and Rejecting tasks through email which has been sent as a part of the Workflow (external task). I have seen a couple of demos showcasing the same?
Can someone let me know how can I implement the same on my workflow? Will "get_servlet_mail_cmd" be of any help ?
Thanx
SunilI
Find more posts tagged with
Comments
Migrateduser
Check out Template Based Email. If you do a search on it in DevNet you should find the tech notes that describe how to use it.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Migrateduser
I think you have better control if you just write the email by hand. Also, the default approve/reject link has some issues:
-It doesn't do very good error control (such as if the task is no longer active if someone else already approved/rejected - it doesn't tell you there's a problem until you click close, then doesn't tell you what the problem is)
-It kicks off launchpad sometimes which can have Java client issues
-It doesn't force the user to enter a comment
-It doesn't let you pass a URL parameter indicating which item should be selected in the drop-down (this is a real problem - users want to click "approve" or "reject" and have it do the right thing, not "transition" and have to remember to change the drop-down - and since the default is usually approve the frequently accidentally approve something they intended to reject)
So I wrote a custom JSP to replace the default approval/rejection UI, and custom code to generate the email message (it basically reads config files and substitutes in the appropriate URLs/text). But before the user gets to that they go to a custom take ownership (for grouptasks) that:
-Takes ownership of the task
-Locks the file(s) to the new owner (if it's not a readonly task), to avoid all the locking issues
-Redirects to the task transition JSP
It's all in Java. I would have to look but I think only transitioning the task requires OpenAPI to support special characters in the transition comment (which can break on command lines) - everything else can be with CLTs.
It took some work but it's really slick. I just wish more real solutions were shipped with the product.
Migrateduser
I kind of like the Template Based Email approach - it's a big improvement over any of the old canned email solutions. I added my own functionality as well. Instead of simply hardcoding Approve and Reject options, I determined what the labels were for the successors of the usertask being assigned to the person receiving the email and used those exact labels as the options for the user to choose from. There may be more options than Approve and Reject. I also figured out a way to allow people outside the TeamSite server to be able to click on an email link and execute an action on a task, without interfacing at all with TeamSite. There are lots of ways to do it - I just think that if you aren't a Java expert, they provided a decent option with Template Based Email. You can customize it however you like.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Migrateduser
The text for the links in the email message can be made to match the items in the transition drop-down by reading the task XML to generate the email, which is the same XML the custom JSP reads to populate the drop-down. But if you are using the default transition dialog, how do you default the selected item in the drop-down (so you can have one link in the email to approve and a separate link to reject)? I couldn't figure out what URL parameter to pass to default the selection.
Migrateduser
Ahhh, good point. I think what I did with this is built a completely custom approach using emails (instead of hyperlinks), which in Solaris can kick off a script. The subject line contains all the pertinent info needed to "do the right thing" with CLTs in the script. So I cheated, basically.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
abhishek_gupta
Hi,
I need to build a WF at the close of a DCT, which triggers of an email to the selected reviewer in the WF screen. The reviewer can Approve / Reject via the email, without looging into TS. I guess John, you have built such kind of a WF. Can you help me out with a bit of description and leads or better if you send the source code (the wft and the email ipl file).
Also, in the email the link of the generated html file needs to be sent rather than the link to the DCR. In all the default WF's with TS, the link to the DCR can be sent. How do I send the link of the generated html page.
Any help would be appreciated.
Thanks,
Abhi
Migrateduser
I would take a serious look at your environment before developing something - specifically, do you want to do this in .wft/Perl/CGI, or in Java? If you want to do this with Perl, replace Java with Perl below and JSP with CGI, and you will have to come up with something where I would use OpenAPI.
You want to trigger a .wft off the tt_data event (in available_templates.cfg). Personally I think the .wft should be a very simple one that just redirects to a JSP page where you can build the drop-down to select the approver. Then use Java to construct the workflow XML, and OpenAPI to instantiate the job.
On the approve/reject I would suggest you use a grouptask instead of a usertask, even though there are some bugs with GroupTask. I would replace the default approve/reject URL with a custom JSP, since the default one has some bugs and you can have better control with a custom one (for instance, if the user clicks the "reject" link in the email, default to "reject" in the drop-down, and the form can force the user to enter a transition comment).
For all links in email messages, I would do a custom Take Ownership URL (since the default one has some issues) that takes ownership of the task, locks the files to the user, etc. It should use OpenAPI to authenticate the user, then redirect to the login screen if that doesn't work (passing a parameter that redirects back to the take ownership screen). Once ownership has been taken it can redirect to the approve/reject url.
I have been looking into ways to avoid the log-in (single sign on) but haven't come up with a solution. Basically you want to find a way to spoof the TeamSite cookie (through httpd.conf I think). You can also modify iw.cfg so the cookies expire less frequently. You could use command line tools to transition the task, and since the JSP/CGI is running as system it wouldn't matter if their cookie was valid, but this could be a security loophole.
As far as the links in the email, typically you have a process before the email process that checks each file associated with the job and attaches the associated DCR or output file(s) - both processes can be part of the same ExternalTask. Then you loop through all of the files in the DCR and write links to each.
If you want to do this in Perl, or quickly, I can't really help you. Even in Java all I could do is send stripped-down code examples.
Edited by john on 04/08/03 08:09 AM (server time).
abhishek_gupta
Thanks for the help John. It would be great if you could send me the working Perl code files, so that I could implement it in a jiffy.
Migrateduser
Like I said, I try to avoid Perl. Here is a .wft that passes the required information to a jsp.
<template_script><![CDATA[
use CGI;
use CMSIdeas::HttpUtil;
#=====================================================================
# CGI_info is used to control the look and feel of the workflow
# instantiation form. See the TeamSite module perldocs and Workflow
# Developer's guide for a list of supported keys and what they are
# used for.
#=====================================================================
#=====================================================================
# For creating the invisible form.
#=====================================================================
my ${cgi} = new CGI;
#=====================================================================
# The content of the form.
#=====================================================================
my ${form} = ${cgi}->startform( -name => "main",
-method => "post",
-action => "/iw/webdesk/Pioneer/JobCreator.jsp", );
#=====================================================================
# Create one hidden element for each file the user had selected.
#=====================================================================
foreach my ${iw_file} ( __VALUE__( 'iw_file' ))
{
${form} .= ${cgi}->hidden( -name => 'iw_file', -default => ${iw_file} );
}
#=====================================================================
# Create additional hidden variables as required.
#=====================================================================
foreach my ${key} ( 'iw_desc', 'iw_session', 'iw_workarea', 'iw_areaowner', 'iw_user', 'iw_role' )
{
${form} .= ${cgi}->hidden( -name => ${key}, -default => __VALUE__( ${key} ) );
}
#=====================================================================
# Close the form and automatically submit it.
#=====================================================================
${form} .= ${cgi}->end_form() . "<SCRIPT>main.submit();</SCRIPT>\n";
#=====================================================================
#=====================================================================
# Hide the Interwoven banner and buttons and write the form.
#=====================================================================
CGI_info( banner_html => '<div style="zindex=1;position:absolute;visibility:visible;left:0;top:0;width:100%;height:100%;background-color:#EEEEEE;"></div>' . ${form}, );
]]></template_script>