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)
Task ID
System
Hi.
I've a Perl script that generates jobs on the fly and executes them. In an external task i'm calling a Perl script that sends e-mail notifications to all approvers. Within this Perl script I dont have the WFID or TaskID. How can i get the taskid( I dont want to use ARGV)?
Thanks
Find more posts tagged with
Comments
Migrateduser
Externaltasks are automatically passed the job ID and task ID.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Migrateduser
How can i get this taskid in my perl script that is being invoked by the externaltask?
Thanks
Migrateduser
All externaltask scripts are passed 4 key values: Job ID, Task ID, Workarea path, Array of files. If you pass no other values to your externaltask script, these variables will be located in
@ARGV
as the first 4 values of the array - note the Files will be referenced by index positions 3..x, where x depends on how many files are attached to your job. So in a typical externaltask script, your first line will be something like this:
my ($jobID, $taskID, $workarea,
@files)
=
@ARGV
;
If you have other values that are required as parameters in your script, they will preceed these special automatic variables. So if you happen to pass in a username to the script your first line would be:
my ($user, $jobID, $taskID, $workarea,
@files)
=
@ARGV
;
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Migrateduser
I pass some parameters also to this external task like the workflow hsitory etc....so I cannot hardcode
@ARGV
value for my $taskid. Is there any other alternative to using
@ARGV
?
Thanks
Migrateduser
That's what I was trying to explain in the second part of my last reply. You can pass ahatever you want to your script - the last 4 variables will always be the standard 4. You can't hope to pass an array of values as your extra parameter though. What does your calling statement look like in your <command> tag?
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Migrateduser
I got it...Thanks.
Migrateduser
I would avoid having workflow pass the files on the command line to the externaltask - you can exceed the command length limit (at least on Windows). Plus the less positional parameters you pass/parse, the better (from my perspective). In fact I wish Interwoven would pass -j jobid -t taskid -a area [-f files] instead of relying on position, as all of my custom parameters use flags like these. Of these only task ID is really needed - you can get the rest (including files) from the task XML. Use the Perl modules or iwgetwfobj and an XML parser to determine what files are associated with the task (since this can change while the task is running anyway, making the command line parameters invalid).
In iw.cfg I always ensure:
[workflow]
external_task_add_filelist=false
And in my command v I pass -i (Interwoven) as the last parameter to my command, to indicate that the remaining parameters are the Interwoven defaults.
Migrateduser
It's not like you have a choice - the files get passed regardless of whether you want them to or not. Whether you choose to grab them from
@ARGV
or gather them from a call to GetFiles() is about the only choice you have.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Migrateduser
I guess I've been on Windows too long - I remember this issue from a long time ago, and it's commented in iw.cfg.example:
[workflow]
## Set 'external_task_add_filelist' to false if you want to prevent
## TeamSite from adding files to the command line of external task
## command callouts. Defaults to true.
#external_task_add_filelist=true
Migrateduser
****...I stand corrected. My mistake.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Adam Stoller
I agree - I generally set the external_task-add_filelist to false and I write my scripts such that the only [automatic] arguments I parse are jobid and taskid - everything else can be derived from there.
my ($jobid, $taskid) =
@ARGV
;
my $task = new TeamSite::WFtask($taskid);
die "Invalid taskid ($taskid)" if (! $task->IsValid());
my $area = $task->GetArea();
my
@files
= $task->GetFiles();
...
This makes it much easier to debug the scripts during development and/or if something seems to go wrong while they're iin use.
--fish
(Interwoven Senior Technical Consultant)