my $task_id = $iw_arg{task};if(defined $task_id) { # Assumes $task_file contains relative path to the file you want to attach set_task_file($task_file, $task_id); }
###################################################################### The following adds a file to the task only if it doesn't exist# Parameters:# $task_file - file to add# $task_id - id of task#####################################################################sub set_task_file { my $task_file = shift; my $task_id = shift; my $file_exists = 0; my $task = new TeamSite::WFtask($task_id); my @files = $task->GetFiles(); # Iterate through task file list for (my $i = 0; $i < @files; $i++) { if($files[$i] eq $task_file) { $file_exists = 1; } } # Add if it doesn't exist if($file_exists == 0) { $task->AddFile($task_file, "Generated from workflow."); }}