Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Workflow email confirmation
seeDerekNow
Hello,
I'm trying to add an external task that simply sends the author an email confirmation once the content is approved by the reviewer. Before I go and hack away at the default mail .ipl scripts, I'd like to know if anyone can provide a sample that they currently use to do this. I'd hate to try and re-invent the wheel.
Thanks,
Derek
Find more posts tagged with
Comments
Migrateduser
Anyone's sample would have to be hacked at anyway to map to your own filesystem and design. Look at the Template Based Email provided in the /solutions directory off of the wft path. There's documentation out there.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
nipper
Is this Unix ?
I write HTML to a file & cat file | mail -t andy
THat works for a short emssage
Be glad to post if you desire
Andy
nipper
Here is my code:
#!/iw-home/iw-perl/bin/iwperl
use TeamSite::WFtask;
use TeamSite::Config;
use TeamSite::WFworkflow;
my $txt = "";
my $wfID = $ARGV[0];
my $taskID = $ARGV[1] ;
my $workarea = $ARGV[2];
my ($task) = new TeamSite::WFtask($taskID);
my $owner = $task->GetOwner();
my($job) = new TeamSite::WFworkflow($wfID);
my($jobdesc) = $job->GetDescription();
$txt = "Subject: Your content has been approved\n";
$txt = $txt . "From: me\
@here
.com\n";
$txt = $txt . <<"END";
Content-type: text/html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META content="MSHTML 6.00.2800.1126" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2>The following job has been approved.
Please go to <A href="
http://teamsite.here.com"><FONT
face=Arial size=2>TeamSite</FONT></A><FONT face=Arial size=2>
for your job.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial><FONT size=2><STRONG>Job ID: </STRONG>
END
$txt .= $wfID . "<br><b>Main Comment:</b> ".$jobdesc."<br>";
$task->GetComments(\
@workcomments)
;
if (
@workcomments){
foreach my $cmt_hash (reverse(
@workcomments))
{
if (! $approver) {
$approver = $cmt_hash->{user};
$jobdesc = $cmt_hash->{body};
$txt .= "<BR><STRONG>Approved By: </STRONG>" . $approver;
$txt .= "<br><b>Review Comment: </b>".$jobdesc."<br>";
}
}
}
$txt= $txt . <<"END";
<SPAN class=283013222-04092003>
</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<B>File List:</B><br>
END
## create WFtask object
my
@files
= $task->GetFiles();
# Create FileList for OD
foreach $file(
@files)
{
$txt .= $file."<br>";
}
$txt .= <<"END";
<DIV> </DIV>
</BODY></HTML>
END
$email_file = "/tmp/email_config_$$";
open (LOG,">$email_file") || die "cannot open \n";
print LOG $txt;
close (LOG);
$ENV {"PATH"} = "";
$cmd='/usr/bin/cat '.$email_file.' | /usr/bin/mail -t '.$owner.'\
@here
.com';
$rc=`$cmd`;
unlink ($email_file);
$task->CallBack(0,"Author worked");
seeDerekNow
Thanks!
Adam Stoller
FYI:
email_file = "/tmp/email_config_$$";
open (LOG,">$email_file") || die "cannot open \n";
print LOG $txt;
close (LOG);
$ENV {"PATH"} = "";
$cmd='/usr/bin/cat '.$email_file.' | /usr/bin/mail -t '.$owner.'\
@here
.com';
$rc=`$cmd`;
unlink ($email_file);
could be simplified with:
my $cmd = "/usr/bin/mail -t $owner\
@here
.com";
if (open(PIPE, "|$cmd")){
print POP $txt;
close(PIPE);
}
no need for a temporary file, nor the need to remove it either; and one less process ('cat') to run.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
brs_template.zip
screenshot.jpg
nipper
life is just not the same without Ghoti to critique your code.
I will take this code & try it. Since I do an open || die in a WF we know
that does not work well.
BTW I assume
my $cmd = "/usr/bin/mail -t $owner\
@here
.com";
if (open(PIPE, "|$cmd")){
print POP $txt;
close(PIPE);
}
The print should be:
print PIPE $txt;
Migrateduser
Although I don't disagree with pointing out how someone could code more efficiently, I think that's the primary reason why many people don't post their code in places like this. Who wants to hear that their coding methods suck? I guess hearing it so much that I now kinda like it doesn't count, eh?
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
nipper
Hey
Are you calling my code ugly ?
Migrateduser
I never said that. But you just did. Guilty conscience? I think your code is very cute.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Migrateduser
Is there some sort of love/hate thing going on between you and nipper? :-)
- Jason
Hamjam
<externaltask name="Editor_Approved"
owner="__TAG__('iw_areaowner');"
description="Editor approved the content Send Email">
<areavpath v="__TAG__('iw_workarea');"/>
<successors>
<successorset description="End">
<succ v="End"/>
</successorset>
</successors>
<command v=' /iw-home/iw-perl/bin/iwperl /iw-home/bin/iwsend_mail.ipl -t "__INSERT__($setgroup);" -s "SOP Change" -b "/iw-home/local/config/wft/solutions/Approve.txt" '/>
<activation>
<pred v="Submit"/>
</activation>
<variables>
<variable key="iw_mailheader_pt" value="reviewer_iwmailheader.tpl"/>
<variable key="iw_mailbody_pt" value="reviewer_iwmailbody.tpl"/>
</variables>
</externaltask>
see if this helps, it takes a text file value and puts it in the body of the mail
Adam Stoller
BTW I assume
my $cmd = "/usr/bin/mail -t $owner\
@here
.com";
if (open(PIPE, "|$cmd")){
print POP $txt;
close(PIPE);
}
The print should be:
print PIPE $txt;
Sigh - yes - I was doing a bunch of things at the same time and forgot to proofread my post - thanks (and unfortunately it's too late to edit it)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Adam Stoller
I think you have task variables associated with
iw_solutions_email.ipl
rather than
iwsend_mail.ipl
and you aren't using the task variables for
iwsend_mail.ipl
, which are recommended to use over stringing everything into the command line. Also, you shouldn't use the
activation
clause unless you need it (generally with an '
and
' or '
or
' clause)
...
<template_script><![CDATA[
use TeamSite::Config;
my $iwhome = TeamSite::Config::iwgethome();
my $mailcmd = "$iwhome/bin/iwsend_mail.ipl";
$mailcmd = "$iwhome/iw-perl/bin/iwperl $mailcmd" if ($^O eq "MSWin32");
]]>
<!-- ... -->
<externaltask name="Editor_Approved"
owner="__TAG__('iw_areaowner');"
description="Editor approved the content Send Email">
<areavpath v="__TAG__('iw_workarea');"/>
<successors>
<successorset description="End">
<succ v="End"/>
</successorset>
</successors>
<!--
<command v='/iw-home/iw-perl/bin/iwperl /iw-home/bin/iwsend_mail.ipl
-t "__INSERT__($setgroup);" -s "SOP Change"
-b "/iw-home/local/config/wft/solutions/Approve.txt" '/>
-->
<command v="__INSERT__($mailcmd);"/>
<!--
<activation>
<pred v="Submit"/>
</activation>
-->
<variables>
<!--
<variable key="iw_mailheader_pt" value="reviewer_iwmailheader.tpl"/>
<variable key="iw_mailbody_pt" value="reviewer_iwmailbody.tpl"/>
-->
<variable key="mail_to" value="__INSERT__($setgroup);"/>
<variable key="mail_subject" value="SOP Change"/>
<variable key="mail_message_file"
value="__INSERT__($iwhome/local/config/wft/solutions/Approve.txt);"/>
</variables>
</externaltask>
<!-- ... -->
(
hopefully I didn't make any bad typos this time
)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com