Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Callback problem
smigster
Has anyone ever experienced this type of problem?
In my workflow I have an external task that evaluates some job variables, sends an email to recipients based on these variables, logs the type of email sent and the next task to be called, then executes a callback to one of two possible tasks -- CallBack(0, ...) for a usertask and CallBack(1, ...) for a grouptask. I've got a few of these types of "Notify, Log, Dispatch" tasks in several workflows and they all work except one that will only transition to the 0th task, even when callback 1 is invoked.
The only possibly "unusual" thing about this workflow is that the start task is an externaltask that does a lot of workflow init type of stuff before doing a callback to one of three possible externaltasks before any basic usertask or grouptask is called. The workflow is initiated via the "Submit" button and there is no startup "new job" or "new job template" screen.
Find more posts tagged with
Comments
Migrateduser
This is a bit confusing - you should post your job spec and the script that is doing the callbacks so it's clear what you are trying to do. Is it possible that the callback is not working because the task you are attempting to callback is not active?
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Migrateduser
Ok, I had to read this a few times before I actually understood what you were trying to say. Did you insert any debug statements into your script to see if (and why) it's simply going down the Callback(0) path all the time? Perhaps your logic is wrong. Post your script and it might be easier to help with this.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
smigster
Dave-
Thanks for chiming in... I sure hope this is a matter of me (and several associates) not SEEING something.
-Gene
Here's the externaltask script:
=================================================
#!/opt/iw-home/iw-perl/bin/iwperl
#
# notify_agency_approver.ipl
# ------------------------------------------------------------------------
# This sends an email notification to the person(s) designated as the EDITOR(s)
# of an agency in the agency_users.dcr control file. This variable has
# already been created by the workflow initialization externaltask so it
# just needs to be retrieved via workflow->getvariable...
# ------------------------------------------------------------------------
use TeamSite::WFtask;
use TeamSite::WFworkflow;
use TeamSite::Config;
my $iwhome = TeamSite::Config::iwgethome();
$iwhome =~ tr|\\|/|; # Replace backslashed with forward slashes.
# Get the value of the job ID, task ID, areavpath.
my ($jobId, $taskId, $areavpath) = (shift, shift, shift);
my $job = TeamSite::WFworkflow->new($jobId);
my $task = TeamSite::WFtask->new($taskId);
# Get job vars & stuff
my $agency_editor = $job->GetVariable('agency_editor');
my $workflow_mode = uc($job->GetVariable('workflow_mode'));
my
@files
= $task->GetFiles();
my $message = "The workflow task below requires your attention for file(s) like $files[0]:";
my $emailcmd = "$iwhome/bin/iwsend_mail.ipl -H -t $agency_editor -m \"$message\" -s \"Author $workflow_mode Approval Request\" $jobId $taskId $areavpath";
my $log = $job->GetVariable('job_log');
# Send the email to the editor(s)
my $result = `$emailcmd 2>&1`;
if ( $agency_editor =~ /,/ ) {
# there is more than one id so callback to the grouptask
Log($log, "Task: NotifyAgencyApprover (GROUP Notification)");
Log($log, "$result");
$task->CallBack(1, "Notified agency approver group: $agency_editor");
} else {
# there is only one so callback to the usertask
Log($log, "Task: NotifyAgencyApprover (USER Notification)");
Log($log, "$result");
$task->CallBack(0, "Notified agency approver: $agency_editor");
}
return;
#---------------------------------------------------------------------
# log
# Updates text file with timestamp and text passed
# ARGUMENTS
# Logfile, text
# RETURNS
# Nothing
#---------------------------------------------------------------------
sub Log
{
my $logfile = shift;
my $logtext = shift;
open LOG, ">>$logfile";
print LOG "[ ", timestamp(), " ] ", $logtext, "\n";
close LOG;
}
#---------------------------------------------------------------------
# timestamp
# Return the current time in the format yyyy-mm-dd hh:mm:ss.
# ARGUMENTS
# None.
# RETURNS
# A string.
#---------------------------------------------------------------------
sub timestamp
{
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime();
$year += 1900;
$mon += 1;
return sprintf("%04d-%02d-%02d %02d:%02d:%02d",
$year, $mon, $mday, $hour, $min, $sec);
}
=================================================
Here are the tasks associated with the code above:
=================================================
<externaltask name = "NotifyAgencyApprover"
lock = "f"
owner = "tsadm1"
retry = "f"
start = "f"
description = "Notify agency approver(s) of pending task"
>
<areavpath v = "__INSERT__($sWA);"/>
<successors>
<successorset description = "Go to AgencyApproval">
<succ v = "AgencyApproval"/>
</successorset>
<successorset description = "Go to GroupAgencyApproval">
<succ v = "GroupAgencyApproval"/>
</successorset>
</successors>
<command v = "/opt/iw-home/custom/nycgov/notify_agency_approver.ipl"/>
<activation>
<or>
<pred v = "InitializeWF"/>
<pred v = "AuthorRework"/>
</or>
</activation>
</externaltask>
<usertask name = "AgencyApproval"
lock = "f"
owner = "tsadm1"
start = "f"
readonly = "f"
description = "Agency editor approves author content"
>
<areavpath v = "__INSERT__($sWA);"/>
<successors>
<successorset description = "Approve">
<succ v = "DispatchByType"/>
</successorset>
<successorset description = "Reject">
<succ v = "NotifyAuthorReject"/>
</successorset>
</successors>
<activation>
<or>
<pred v = "NotifyAgencyApprover"/>
<pred v = "NotifyAgencyReject"/>
</or>
</activation>
</usertask>
<grouptask name = "GroupAgencyApproval"
lock = "f"
start = "f"
readonly = "t"
description = "Group of agency editors approves author content"
retainowner = "f"
>
<areavpath v = "__INSERT__($sWA);"/>
<successors>
<successorset description = "Approve">
<succ v = "DispatchByType"/>
</successorset>
<successorset description = "Reject">
<succ v = "NotifyAuthorReject"/>
</successorset>
</successors>
<sharedby>
<user v = "tsadm1"/>
</sharedby>
<activation>
<or>
<pred v = "NotifyAgencyApprover"/>
<pred v = "NotifyAgencyReject"/>
</or>
</activation>
</grouptask>
=================================================
Migrateduser
OK, this is the statement I would key on:
if ( $agency_editor =~ /,/ ) {
What is the actual value of $agency_editor when it reaches this statement - print that out to your log file and paste the output of your debug log in your next post. I suspect this regex is not matching and is always going to the
else
path.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
smigster
As I mentioned in my original post, I log all actions taken during the workflow. The logs indicate that the correct decision is always being made.
The $agency_editor variable contains either a single ID (like "ahoffman") or multiple IDs separated by commas (like "ahoffman,aglover"). Very simple and, again, the prerequistes to the callback are always correct. In the logs I always see entries for email going to multiple recipients and the callback comment indicating that the grouptask would be coming next even though the workflow engine refuses to callback to it.
One VERY important thing I forgot to mention is that when I flip-flop the user & group task, so the grouptask gets the callback 0, the grouptask is the one that always happens. The callback 1 never happens.
I'm beginning to think that I've fallen into some weird bug in TeamSite workflow engine.
Migrateduser
Just for giggles, instead of using this:
$task->CallBack(1,...
try calling the CLT and see if that makes a difference:
`.../iw-home/bin/iwcallback $taskID 1`;
I always use the CLT and I have done similar things as you are doing with no troubles. It's worth a try anyway.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Adam Stoller
I've used $task->CallBack() with different values from scripts many times, and never had a problem with it.
You did indicate (didn't you) that the log is showing the "GROUP Notification" message - can you confirm that?
Although rarely checked (to my knowledge) the CallBack method is supposed to return two values - you might want to check them in your script and log the results.
-------------
($success, $immediatetask) = CallBack($retcode, $comment)
Comment should be specified in UTF-8 encoding.
Callback from a cgitask or externaltask. $immediatetask
is a possibly invalid TeamSite::WFtask to run.
----------
--fish
(Interwoven Senior Technical Consultant)
smigster
I will try this and let you know. THANKS!
smigster
Switching to the CLT made no difference.
jbonifaci
First of all, I've written a lot of external tasks, and like fish, have never had any problems with this. Have you verified that you are getting to the callback(1,"") line as fish suggested?
Also, two things I'd be curious for you to try:
1) change both of your callbacks to 1 and see what happens.
2) hard code $agency_editor to something with a comma in it, or just do if (1) or something that is always true and see what happens.
smigster
1. Even when both callbacks are set to 1 the workflow still transitions to the 0th task.
2. I don't have to hardcode anything with a comma in it 'cause the logs show me the value of $agency_editor -- and it is always the expected value in either context (single editor, multiple editors).
Again, the logic is correct and has been verified by several people (including another Interwoven alumnus) by looking at the code and the logs.
Looks like it's time to change the workflow around to set up two notification streams instead of the one task with two callbacks.
Adam Stoller
Please post - as an attachment - a zip (or tar) file containing the wft and the script - and please make sure that these are the actual wft and script you are running (more times than I can count, someone [including me] has been stymied for hours trying to fix a bug in the wrong code).
--fish
(Interwoven Senior Technical Consultant)
smigster
Thanks for wanting to drill down into this further. We're pursuing a resolution to this with IW tech support so it would probably better to throw the scripts and other environment info at them. Meanwhile, I've implemented a workaround so the pressure is not so heavy to fix this now.
I've been wanting to try this out on the TS6 beta. Do you know if the workflow engine has been enanced at all in the new version or was simply bundled as is? If it wasn't changed at all I won't bother.
Adam Stoller
I don't think there's been any significant changes in TS6 with respect to this issue - but by all means, if you have a beta, try it out - and provide feedback on the beta forums.
--fish
(Interwoven Senior Technical Consultant)
Migrateduser
I believe Interwoven has been pushing this release as a UI improvement only release. Backend changes will be in the next major release, sometime next year.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Migrateduser
To my knowledge there are no major workflow engine changes. There are out of the box example changes. regards,
lissa
deepak
Hi,
I encountered the very same problem last week in my workflow. After much digging I figured that it was the "iwsend_mail.ipl" script that was causing the problem. If you look at the code of it has internal calls to
" task->CallBack(...,...)" based on email notification success or failure.
In case of a email notification callback (0, "comment) is called. I bet that is the problem with your workflow as it was with mine.
I have restored to a custom email script to get around this. Hope this helps. Why the send mail script is coded that way might be better answered by "fish" or interwoven support staff.
Deepak
Bubas_IWOV
Hi,
To what concerns version 6 and 6.1, its only new gui and DDA compliance. now with version 6.5 then, the backhand chagnes come in, implicating changes to both workflow and templating modules.
In terms of the workflow transition, i would say try to confirm that the value you getting in your script is really "0" or "1" . The strange part is that the workflow never stops, isnt?
Regards
Bruno
Adam Stoller
Doh! Good spotting deepak!
Yes - iwsend_mail.ipl was written to be a stand-alone externaltask script - as such it performs it's own callback to the workflow engine - so you cannot use within another externaltask script unless it's the last part of the process and you want the callback values that it is going to use.
At one point I was considering trying to turn iwsend_mail.ipl into a module (iwsend_mail.pm) - but I've constantly gotten side-tracked from doing that - plus, the move is generally towards the iw_solutions_email.ipl script in place of iwsend_mail.ipl, so it isn't clear that focusing time on iwsend_mail.ipl => iwsend_mail.pm would be very productive.
If you want to use iwsend_mail.ipl as a script within a script - make a copy of it (like into IWHOME/local/bin/company_sendmail.ipl) and modify the copy to either just exit (if you don't care about mail failures as specific events) or exit with either a zero or non-zero value (if you do care) - then just call your local copy of the script in place of the one that ships with TeamSite.
Shame on me for missing that the first time around... must have been one of those nights I didn't sleep ;-)
--fish
(Interwoven Senior Technical Consultant)
Migrateduser
Is it possible for Callback() to return just one value, ie, would Callback(0) work without any adverse effects?
amolivar
Adam Stoller
If you're asking if the second parameter to $task->CallBack(idx, msg) is required - I believe the answer is no - but it's generally a good thing to provide as it aids in tracking status of the job as it transitions from task to task.
If you're asking something else - please elaborate.
--fish
(Interwoven Senior Technical Consultant)
Migrateduser
That is exactly what I was asking. I was only going to remove it from some of the callbacks as they are showing up in the email notifications that users really don't need to see, like the comment "Task completed" generated by the system. I'd like to limit the comments in the notifications to user inputs. If ever, I could put it back there for debugging purposes in the future.
I was kinda hesistant to take it out because it might just do something unexpected or just remove some other functionalities that I have not tracked yet. I did experiment with taking the second argument out, and haven't found anything detrimental so far.
Thank you for your input.
amolivar