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)
Callback on CGI task
System
I'm using TS 5.5.2. Did anyone experience the following problem before?
I have a CGI task, it has the following successors defined:
<successors>
<successorset description="Approve">
<succ v="TaskX"/>
</successorset>
<successorset description="Reject">
<succ v="TaskY"/>
</successorset>
</successors>
If I execute:
iwcallback <myCGI task id> "Reject" "my comments"
The workflow made transition to TaskX, not TaskY!
If I execute:
iwcallback <myCGI task id> 1 "my comments"
It made the proper transition to TaskY.
According to the manual, the above 2 command should give me the same result. Any suggestions on how to make it work without using the numerical return code? Since the iwcallback command needs to exist in a shared script, which can be used to reject tasks from any workflow templates. There is no guarantee that al the workflow templates specify the "Reject" successorset after the "Approve" one.
Thanks in advance!
Find more posts tagged with
Comments
Adam Stoller
Are you talking about the iwcallback CLT or the Perl TeamSite::CGI_lite::iwcallback() method?
The CLT expects index numbers: iwcallback taskid zero-based-index-number "comment"
The TeamSite::WFtask::CallBack() method is the same: $task->CallBac(zero-based-index-number, "comment");
The TeamSite::CGI_lite::iwcallback() method is different ($cgi->iwcallback("transition-description", "comment");
The last one is what I believe you want.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Migrateduser
Here is some existing code by someone else that I'm debugging:
#!/iw-home/iw-perl/bin/iwperl
use strict;
use CGI;
use TeamSite::Config;
use TeamSite::WFtask;
my $query = new CGI;
my $taskid = $query->param('taskid');
my $comments = $query->param('comments');
(my $iwhome = TeamSite::Config::iwgethome()) =~ tr|\\|/|;
my($task) = new TeamSite::WFtask($taskid);
my $task_owner = $task->GetOwner();
my $cgi = new CGI;
print
$cgi->header .
$cgi->start_html('Rejection Confirmation'),
$cgi->h3("Rejecting task id $taskid with comments:"),
$cgi->h4("$comments");
my $output = $task->CallBack("Reject", "$comments");
print $cgi->h3("$output");
print $cgi->h3(length($output));
if (length($output) > 0)
{
print $cgi->h3("<font>The rejection was successfully completed. </font>");
}
else
{
print $cgi->h3("<font color=red>It appears that you have already acted on this workflow. </font>");
}
print $cgi->end_html;
exit (0);
It is using $task->CallBack and it is not working. So I probably need to switch to use the iwcallback() in TeamSite::CGI_lite. However, what I don't understand is, how would the iwcallback() know what task id to callback?
Thanks.
mgal
By looking at the iwcallback method of CGI_Lite.pm it seems like it takes the taskid of the current task to callback.
From CGI_Lite.pm
# Special variable mangling for iwcallback.cgi
$this->{form}{return_page} = 'tasks_list';
if (ref $this->{form}{task_id})
{
$this->{form}{task_id} = $this->{form}{task_id}[0];
}
Thxs,
Mohammed Gazal.
Adam Stoller
In order to use TeamSite::CGI_lite, you'll have to(*) replace your usage of CGI with TeamSite::CGI_lite - it's not directly a 1:1 mapping, so the code will change.
One of the things that TeamSite::CGI_lite objects know about is workflow - so the iwcallback() method already inherently knows the taskid - all you need to supply is the task transition description and a comment.
I'd suggest looking at the perldoc for TeamSite::CGI_lite, the Workflow Tutorial (available on DevNet) or a recent copy of the Workflow Developers Guide - for more information about how to write cgitask scripts with this module.
What you'll lose is the built-in functions for generating HTML output (like 'header', 'start_html', etc.).
What you'll gain is the ability to interact with Workflow the way you're asking about.
(* "have to" is not 100% correct, you *can* use both modules together, but you have to do some voodoo with the query string because both modules are going to want to read it in - I don't remember the voodoo though - sorry)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Migrateduser
Thanks for the explainations from all of you. The CGI script that needs to perform the callback is unfortunetly not a cgi task. It's an independent cgi script, a workflow email embeds this cgi script, passing it the task id to which it needs to send callback.
I guess in this case I can't really use cgi->iwcallback(). My only choice to fix the script would be to change it to use the numerical index.
JonathonG
You say the email passes the task id to which it needs to callback...I believe you can use cgi->iwcallback as long as the task id is passed as the parameter named "task_id". (I took a quick glance at the cgi_lite.pm and it looks like that's what its referencing for the task id.)
Jonathon
Independent Interwoven Contractor
Migrateduser
I past a parameter named "task_id" as follows:
my $cgi = TeamSite::CGI_lite->new();
$cgi->parse_data();
my $taskid = $cgi->{form}{task_id};
my $comments = $cgi->{form}{'comments'};
(my $iwhome = TeamSite::Config::iwgethome()) =~ tr|\\|/|;
my($task) = new TeamSite::WFtask($taskid);
my $task_owner = $task->GetOwner();
The task id and comments displayed properly in the browser. Then I added:
my $output = $cgi->iwcallback("Reject", "$comments");
I got error message: TeamSite: Workflow Custom CGI Callback
Error: Error in iwcallback usage: Missing 'session' argument
required parameters: session - the session string
...
JonathonG
Grrr...session. Sorry, I forgot about that one. Since this is coming from an email, I don't know that there's any way to generate a valid session to send to your CGI. Looks like your initial conclusion may have been right, you can't use cgi_lite->callback. I'm sorry if I cost you time.
Jonathon
Independent Interwoven Contractor