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)
gathering info from DCR
MattP
For some reason, I can't find documentation on this...although I am sure there is some.
How do I pass a value from a dcr to a WF? For example, If the user inserts an image path, I want my WF to receive the path from the DCR so the file can be added to the WF and submitted.
Thanks, sorry for the basic question.
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
Find more posts tagged with
Comments
mogoo
Ooooo... good question, Matt! I suppose you could always parse through the DCR via an external task... or can you use TeamSite:
CRnode and/or iwperl within template_script in workflows? You're right... this seems like something that should be built in, OOTB.
Good luck, I'll be curious to see what people come up with...
maureen
jbonifaci
Matt,
If the dcr(s) are attached when the workflow is started, you can do it within workflow template. If the dcrs are attached at some other point, you can do it with an external task (you can do it with an external task either way).
This code for the wft should help you do it at instantiation:
######################################################################
######################################################################
## BEGIN CODE
######################################################################
######################################################################
# Import routines from library
use TeamSite::Usertask qw(
cleanup_paths
);
use TeamSite::Config;
use TeamSite::XMLnode;
######################################################################
# Name: set_area
# Args: btag - TAG_info variable name for branch path.
# watag - TAG_info variable name for workarea.
# Usage: ($a, $b, $w, $s) = set_area("$btag", "$watag");
# Purpose: If the built-in variables for branch and workarea have
# not been set, pull the information from the workflow
# instantiation form (using the btag and watag info).
# Use the branch and workarea information to generate
# a valid areavpath (using a library routine)
# Returns: Returns the generated areavpath, the branch path, the
# workarea name, and a boolean indicating whether or not
# the branch and workarea need to be prompted for during
# instantiation (this relies on the fact that this code
# is run multiple times during the instantion process).
######################################################################
sub set_area{
my($btag, $watag) =
@_
;
my($avpath, $bpath, $wapath, $skip);
my($iwbpath, $iwwapath) = (__VALUE__("iw_branch"),
__VALUE__("iw_workarea"));
if ((length($iwbpath)) > 0 && (length($iwwapath)) > 0){
$bpath = $iwbpath;
($wapath = $iwwapath) =~ s|^\s*/.*
|;
$wapath =~ s|/\s*$||;
return("$wapath", "$iwbpath", "$wapath", "TRUE");
}
($bpath, $wapath, $avpath) = cleanup_paths(__VALUE__("$btag"),
__VALUE__("$watag"));
return("$avpath", "$bpath", "$wapath", "FALSE");
}
my($area_vpath, $branch_path, $work_area, $skip_branch) =
set_area("branch_path", "work_area");
######################################################################
# get location of iwhome, iwmount and define location of iwextattr
######################################################################
my $iwhome = TeamSite::Config::iwgethome();
my $iwmount = TeamSite::Config::iwgetmount();
my $iwextattr = "$iwhome/bin/iwextattr";
######################################################################
# retrieve the list of files submitted
######################################################################
my
@submit_files
= ();
if (__ELEM__('iw_file'))
{
@submit_files
= map { TeamSite::CGI_lite::escape_html_data($_);
} sort __VALUE__('iw_file');
}
######################################################################
# retrieve the image file path(s) from the dcr(s)
######################################################################
my
@image_files
;
foreach my $submit_file (
@submit_files)
{
# check if the file is a dcr
if (`$iwextattr -g TeamSite/Templating/DCR/Type $iwmount$area_vpath$submit_file`)
{
open(XML, "<$iwmount$area_vpath$submit_file") || die "Cannot open $iwmount$area_vpath$submit_file: $!\n";
my $xml = join ("", <XML>);
close(XML);
my $rootnode = TeamSite::XMLnode->new($xml);
my $image_path = $rootnode->value('IMAGE_PATH');
push(
@image_files
, $image_path);
}
}
push(
@submit_files
,
@image_files)
;
######################################################################
######################################################################
## END CODE
######################################################################
######################################################################
And then in your start task, you'll want to attach the files with something like this:
######################################################################
######################################################################
## BEGIN CODE
######################################################################
######################################################################
<files>
<template_script><![CDATA[
if (
@submit_file
!= 0)
{
for (my $i=0; $i <
@submit_files
; ++$i)
{
__INSERT__("
<file path='$submit_files[$i]' " .
"comment='__TAG__(File_comment_$i);'/>");
}
}
]]></template_script>
</files>
######################################################################
######################################################################
## END CODE
######################################################################
######################################################################
If you want to attach the image files in an external task, you could do something like this
######################################################################
######################################################################
## BEGIN CODE
######################################################################
######################################################################
#!d:\iw-home/iw-perl/bin/iwperl
use TeamSite::WFtask;
use TeamSite::Config;
use TeamSite::XMLnode;
my $iwhome = TeamSite::Config::iwgethome();
my $iwmount = TeamSite::Config::iwgetmount();
my $iwextattr = "$iwhome/bin/iwextattr";
my $wfid = shift
@ARGV
;
my $taskid = shift
@ARGV
;
my $task = new TeamSite::WFtask($taskid);
my
@files
= $task->GetFiles();
my $workarea = $task->GetArea();
foreach my $file (
@files)
{
# check if the file is a dcr
if (`$iwextattr -g TeamSite/Templating/DCR/Type $workarea\\$file`)
{
open(XML, "<$workarea\\$file") || die "Cannot open $workarea\\$file: $!\n";
my $xml = join ("", <XML>);
close(XML);
my $rootnode = TeamSite::XMLnode->new($xml);
my $image_path = $rootnode->value('IMAGE_PATH');
$task->AddFile($image_path, "added via external script")
}
}
$task->CallBack(0, "Image Files Attached")
######################################################################
######################################################################
## END CODE
######################################################################
######################################################################
Hope this helps,
Jeff
MattP
It does help very much.
Thanks, I will work through it.
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA