How do I dynamically attach files to an inactive task?
How do I dynamically attach files to an inactive task. I have an external task which generates a list of dependent files which I want to attach to an inactive "Submit" task. Is there a better way for achieving the same thing
A file can be attached to the job through any cgi/external task. Logically it is said to attach files to the task.. but in actual it gets associated with the job.
Thanks for your feedback. I am attaching the files in my external task. I am having a loop where I am adding the files to the task. I am getting a strange problem where only the last file get added to the workflow file list. What can be ther reason for that....I am also tried printing $task->GetError which shows as blank.
if (open FILE, "$dcrfile.txt") { my @alist = map{chomp; $_} <FILE>; $task->AddMultipleFiles(\@alist, "Adding dependent file to file list for submission"); close FILE;} else { $task->CallBack(1, "Unable to open $dcrfile.txt $!");};
In my external task currently I am creating a unique list before adding. But that can also fail if the task will be executed again if there is a rejection in my approval task. One way is to loop through each and every file in GetFiles() but that's awkward. Is there a way to avoid custom coding in here - if (open FILE, "$dcrfile.txt"){ my @arrFiles = map {chomp; $_} ; close FILE; debug ("Adding dependent files to the DCR"); undef %saw;@arrUnique = grep(!$saw{$_}++, @arrFiles); $task->AddMultipleFiles(\@arrUnique, "Adding dependent file to file list for submission"); my $error = $task->GetError(); debug ("Error after adding the files : $error");} else{ $task->CallBack(1, "ERROR ADDING DEPENDENT FILES TO FILELIST FOR SUBMISSION"); exit -1; }
my %files;foreach my $f ($task->GetFiles()){ $files{$f} = q();}if (open FILE, "$dcrfile.txt") {my @newFiles; foreach my $f (<FILE>){ chomp($f); if (!defined($files{$f})){ push(@newFiles, $f); } } close FILE; debug ("Adding dependent files to the DCR");newFiles, "Adding dependent file to file list for submission"); my $error = $task->GetError(); debug ("Error after adding the files : $error");} else { $task->CallBack(1, "ERROR ADDING DEPENDENT FILES TO FILELIST FOR SUBMISSION"); exit -1; }
... if (!defined($files{$f})){ push(@newFiles, $f);$files{$f} = q(); }...
Thanks for the feedback guys....I did something like that to check for existing files.....I thought AddMultipleFiles/AddFile should handle cases like "File already exists" instead of throwing error....