Home
TeamSite
how to pass item value from DCR to custom script
sachin_sharma78
Hi friends,
i m facing a problem which is causing headache. I have a custom script which expects 1 parameter from the DCR item value. Can anybody tell me how can i pass the value to the custome script ?
any help will b greatly appreciated.
regards,
sachin
Find more posts tagged with
Comments
Migrateduser
You'll need to be more explicit -- how are you calling this script? Where is the value coming from, specifically? etc., etc.....
Dave
Current Environment(s):
(1) TS 6.1 SP1 on W2K3
(2) TS 6.1 SP1 on W2K
(3) TS 5.5.2 SP2 on Win2K
sachin_sharma78
Thanx Dave,
Actually I have a metadata in DCR which contains the value = "Internet/press-release/news". when i generate the html using external script which is called by workflow the html is saved in a folder hard-coded in external script, I want script to automatically create the folders as "Internet/press-release/news" automatically (which is done by open deploy) and save the html file in news folder. so how can metadata value be passed to external script so that html file can be saved in desired directory.
here is the script attached
use TeamSite::WFtask;
use TeamSite::WFworkflow;
my $iwhome = TeamSite::Config::iwgethome();
my $iwmount = TeamSite::Config::iwgetmount();
#Change the debug bit to 1, if you want the logs to be generated to a file "$iwhome/tmp/gen_html_$$.log";
my $debug = 0;
debug("--------- gen_html.ipl called from workflow ---------");
my $taskid = $ARGV[1]; ##Variable passed from workflow.
my($task) = TeamSite::WFtask->new($taskid);
my $areavpath = $ARGV[2];
debug("JobID == $ARGV[0] TaskID == $ARGV[1] AreaVpath = $ARGV[2] ");
my
@dcrFiles
= $task->GetFiles();
my ($dcrName,$presentation,$presentation1,$outputName);
$task->CallBack();
for(my $i=0;$i<=
@dcrFiles
;$i++){
if (($dcrFiles[$i] =~ /.*templatedata.*data.*/)){
$dcrName = $areavpath."\\".$dcrFiles[$i];
debug("Attached DCR name = $dcrFiles[$i] ");
$dcrName =~m /(.*)data\\(.*)/; #Parse the DCR path to get presentaion type and DCR name.
print $dcrName;
$presentation="$iwmount$1presentation\\"; ##We are reading the directory structure so we need to append iwmount.
$presentation1="$1presentation\\";
my $temp = $2;
#$outputName = "/internet/press-release/news/$temp.html" if( $dcrName =~ /.*targeted_content.*/); ## rite now i m hardcoding the name.
debug("Generated outputName = $outputName ");
}
}
#print $dcrFiles[0];
# Code to get the tpl list. Loop through the directory and get the list of tpl's.
opendir(DIR,"$presentation");
my
@dirList
= readdir DIR;
closedir DIR;
shift
@dirList
; #no more .
shift
@dirList
; #no more ..
my $gen_cmd1 = "$iwhome/bin/iwgen " . " -t " . $presentation1 .
@dirList[0]
. " -r " .$dcrName . " " . $areavpath . $outputName;
debug("Generate command = $gen_cmd1 ");
my $retval = system($gen_cmd1);
debug("Value returned = $retval If this value is not 0 we are in trouble.");
##Add generated output file to workflow.
$task->AddFile($outputName, "html");
if(!$retval) {
$task->CallBack(0, 'Success');
}
else{
$task->CallBack(1, 'FAILURE');
}
exit(0);
Adam Stoller
Your question is a bit vague and confusing - you posted code but didn't clearly identify where in that code your problem exists and what the nature of the problem is.
If you want to extract a value from a DCR - look at the perldoc for TeamSite:
CRnode or similar.
If you want to extract a value from metadat attached to (not in) an asset - look at the documentation for the iwextattr CLT.
If you want to create directory structures associated with a given path - look at the perldoc for File:
ath.
If the above doesn't help you - try to express your question more clearly and concisely.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
sachin_sharma78
Actually I have a metadata named "community" in DCR (for example its value is "Internet/press-release/news".)
when i click on finish tab of my DCR it triggers my workflow. In my workflow i m calling 2 external scripts to generate the html and deploying it to teamsite and staging server respectively. Now when i deploy my html page to teamsite server I want it to be saved in news directory (the main directory inside templatedata should be Internet, inside which press-release should exist and inside press-release, news should exist. If any of this directory doent exist then that directory and its sub directory should be created automatically.) so basically i have to pass the metadata value to my workflowv and i dont know how do it. I m storing my metadata items and DCR items in a single page and I am calling an external script in my datacapture.cfg for metadata items.
gzevin
you could parse your DCR from the external task and set the retrieved value as a workflow variable.
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
Adam Stoller
As Greg indicated, the retrieved value can be stored in a workflow variable which will allow you to access it from multiple tasks within the workflow - as for how to retrieve it and how to create the directories - I believe I answered that already.
Does that answer your questions or are you still not understanding something?
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com