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)
Transition Comments
Paul
Is it possible to capture Transition Comments and include them in email notifications to task owner(s)
Find more posts tagged with
Comments
Adam Stoller
I believe that TeamSite::WFtask::GetComents() is what you're looking for. Check out perldoc TeamSite::WFtask for more details.
--fish
(Interwoven Senior Technical Consultant)
Paul
OK. here's a really silly question. Just how do I access the perldoc? I can do it on a solaris box but I have TeamSite running on an NT box and it's a remose box on top of that?
Any advice?
Paul
OK here's what I have in my send_email.ipl script Things never get sent out until I comment out the line that begins with $comment. Looking at the perldoc for WFTask($GetComment) I think I may be missing something here. Can someone prod me towards the light on this one?
use TeamSite::WFtask;
use TeamSite::WFworkflow;
use TeamSite::Config;
my $task = new TeamSite::WFtask($ARGV[2]);
my $comment = $task->$GetComments();
my $workflow_id = $ARGV[1];
my $workflow = new TeamSite::WFworkflow($workflow_id);
my $taskowner = $task->GetOwner();
my $iwhome = TeamSite::Config::iwgethome();
my $areavpath = $task->GetArea();
my $task_id = $task->GetId();
my $wfdescription = $workflow->GetDescription();
my $wfowner = $workflow->GetOwner();
my $wfcreator = $workflow->GetCreator();
my $taskdescription = $task->GetDescription();
Migrateduser
Here are the perldoc lines for the GetComments method in WFtask.pm:
GetComments(\
@list)
Gets the comments for the task as an array of hashes, each
with keys of 'date', 'task', 'user', and 'body'.
So it looks like you pass in a reference to an array and it loads up that array. The perldoc provides you with a very limited level of documentation. There is no detailed level of documentation for the perl modules Interwoven supplies - if you can't figure it out by reading the code, you're pretty much screwed.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Paul
OK so based upon that section in the perldoc file. I should have something in the parentheses after the GetComments()
Maybe something like
GetComments(
@_[1])
;
or
GetComments(
@ARGV[1])
;
however this seems to hang the server too. I can't see any error messages or anything but the notification to the Content Creator never gets sent and the job kust hangs in the queue at the notification (external) task
Migrateduser
No, that's wrong. You need to create an array and pass its reference into the method, like this:
my
@comments
= ();
$task->GetComments(\
@comments)
;
Then the results should be in your
@comments
array. But remember it's an array of hashes.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Paul
It's been a while since I've workes with hashes
So then
@Comments
will have the keys:
date
task
user
body
and to get the value of the task pair I will need to do something like:
$TheComments = keys %{$Comment[$1]}
maybe?
Migrateduser
Well sort of, but that's not what you should do. I would do it like this:
my
@comments
= ();
$task->GetComments(\
@comments)
;
foreach (
@comments)
{
print "date: " . $_{date} . "\n";
print "task: " . $_{task} . "\n";
print "user: " . $_{user} . "\n";
print "body: " . $_{body} . "\n";
}
Something like that.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Paul
Thanks for your time Dave I really appreciate this.
OK I see what you are saying here. Is it safe to assume that the latest comment hash will be appended to the end of the array? Because what I ultimately want to do is to include just the task comment in the body of the email message that is going out.
Also the commented line seems to hang things up. don't I need some sort of variable name here?
my $task = new TeamSite::WFtask($ARGV[2]);
my
@comments
= ();
#$task->$GetComments(\
@comments)
;
my $workflow_id = $ARGV[1];
...
Ah HA!
Here's the error message
Can't Locate object method "" via package "TeamSite::WFTask" at c:\iw-home\cigna\bin\send_email.ipl line 23
Migrateduser
You have an extra dollar sign in there get rid of the dollar sign in red:
$task->
$
GetComments(\
@comments)
;
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Paul
I just found the extra dollar sign too. I removed it and here's the next error message
Task 0 does not exist.
ERROR:00920" Object being looked up was not found.
I would expect that to be true because for this first set of emails there are NO comments.
Migrateduser
Well, unless you're passing in an extra parameter, $ARGV[2] will not be your taskID. It's usually $ARGV[1]. You should print out your
@ARGV
elements to make sure you are looking at the right ones.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Paul
OK the ONLY value in ARGV is the TaskID which is of course $ARGV[0]
I am not understanding the error message unless it is coming in further down the code. I will look through the script and see if I may have introduced something evil.
Paul
The error was coming only when I ran the script from the command line so that probably indicates that I needed to include more parameters in the command. No biggie.
However I am still not getting the transition comments out of the array of hashes properly.
What is the fundamental flaw in this piece of code?
(adding the second line causes it to hang)
$task->GetComments(\
@comments)
;
$transComment =
@comments($_{task})
;
Migrateduser
The flaw is that your syntax is completely wrong. You seem to be flailing a bit with perl syntax, and you really should sit down with the Learning Perl book (O'Reilly) and try and understand the basics of the main data types of perl. Someone could write this code for you (I thought I already did) but that won't help you with the next script you will have to write. You are fooling yourself if you think you can support this product at the script writing level and not understand the fundamentals of perl.
As far as this line goes:
$transComment =
@comments($_{task})
;
I don't even know what you are trying to do with this.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Paul
It is amazing what a little time with the proper resource material can do.
What I was trying to do with that last line of code was to dump the comments into a variable that could be used in the body of the message. Using the above example, what I came up with is:
my
@list
= ();
$task->GetComments(\
@list)
;
my $comMsg = "\n";
foreach (
@list)
{
$comMsg = $comMsg . "date: " . $_{date} . "\ntask: " . $_{task} . "\nuser: " . $_{user} . "\nbody: " . $_{body} . "\n\n";
}
and the script doesn't break. However there are two things I am seeing.
1. The array of hashes appears to be getting TWO new hashes with each transition.
2. The values of those new hashes are empty.
What is being returned in the body of the email is:
date:
task:
user:
body:
date:
task:
user:
body:
And I get two new ones each time I transition.
Migrateduser
When I tested mine out, I got empty hash keys as well. I'm not really sure why this function works the way it does. It exists in the WFtask.pm module, yet it appears to try and return a hash for every task in the job. That would lead me to believe it belongs in WFworkflow.pm. But since the hashes it returns are all empty, I can't really tell what it does. Has anyone ever used this function successfully?
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Paul
If we can get this to work what I really need is the last transition comment I could always do a reverse(
@list)
and then only grab the first one.
I would be interested in knowing if anyone has ever gotten this to work or if I/we may be missing something in the way the array gets set/populated. However, since I do get additional returns each time I transition, I can only assume that something is getting set somewhere.
Paul
OK here we go.
change my
@list
= ();
$task->GetComments(\
@list)
;
my $comMsg = "\n";
foreach (
@list)
{
$comMsg = $comMsg . "date: " . $_{date} . "\ntask: " . $_{task} . "\nuser: " . $_{user} . "\nbody: " . $_{body} . "\n\n";
}
to my
@list
= ();
$task->GetComments(\
@list)
;
my $comMsg = "\n";
foreach (
@list)
{
$comMsg = $comMsg . "date: " . $_->{date} . "\ntask: " . $_->{task} . "\nuser: " . $_->{user} . "\nbody: " . $_->{body} . "\n\n";
}
And it works. However I still get two hashes for each transition. It appears that a hash is added after each email as well as after each transition.
Migrateduser
That means the documentation is wrong (what a surprise). It should say that it returns an array of hashrefs, not an array of hashes. Interwoven really needs to clean up its act with its documentation.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Adam Stoller
However I still get two hashes for each transition. It appears that a hash is added after each email as well as after each transition.
You should get a transition comment for the transiton into the email task and you get another one for the comment supplied as part of the CallBack in the email task.
Does this jive with what you are seeing?
--fish
(Interwoven Senior Technical Consultant)
Adam Stoller
FYI: I just saw a bug report get filed for this today (#36724)
--fish
(Interwoven Senior Technical Consultant)
B80116
Just wanted to thank everyone who contributed to this thread.
It really helped me a lot today!