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)
Job Variables
John742
Seems Like this subject has alot of posts and I am still unable to get my wft to recognize a job variable. Sorry in advance, but I must me overlooking something.
TS 6.5 on Sol 9
I need to pass a variable(one) from a CGI task back to the workflow and then on to the next task. Here is my code in the CGI task:
my $name = "time";
my $value = "this variable";
my $jobId = $task->GetWorkflowId;
my $job = TeamSite::WFworkflow->new($jobId);
#Set Workflow var for scheduled time
$job->CreateVariable($name, $value);
At this point since I have used Createvariable instead of Setvariable the variable should be availabe to the workflow. What am I missing on the workflow side? Thanks!!
J Dagenhardt
Find more posts tagged with
Comments
brandon1
This is incorrect and GetWorkflowId will work without ().
Thanks to JonathonG for pointing out in the words of jbonifaci that "I am on crack"
my $jobId = $task->GetWorkflowId
()
;
GetWorkflowId is a method not a property.
Current Project: TS 6.1
Environment: Windows
Adam Stoller
Besides what brandon pointed out
- CreateVariable can only be used once - when the variable is not yet defined in the wft/workflow.
- SetVariable can be used multiple times - but only after the variable has been defined/created in the wft/workflow.
Generally, if you know you are going to use a job variable - it's better/simpler to define it in the wft and then just use SetVariable() in your externaltask/cgitask scripts.
You should also be verifying that the job and task objects are valid using IsValid() before trying to reference/manipulate any part of the object.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
John742
Thanks for the info.
RE: it's better/simpler to define it in the wft and then just use SetVariable() in your externaltask/cgitask scripts.
Is there something special about defining it in the worflow? Does it have to be defined between variable tags or will adding it to the perl script work ok?
J Dagenhardt
brandon1
They need to be defined within a variables tag.
<variables>
<variable key='name' value="value" />
</variables>
Current Project: TS 6.1
Environment: Windows
JonathonG
Or, if using the WFconstructor module, use set_job_variable
Jonathon
Interwoven Developer
Allstate, Inc.
John742
Since I declared it within the variables tag, does this mean I have to create a job object in the workflow itself to retreive this value? I need the actual value available in the workflow. (I will be using this as a value for <timeout> in a task).
J Dagenhardt
jbonifaci
"in the workflow itself"
What do you mean by this? Before you instantiate it? The workflow doesn't exist before you instantiate it, so you can't use the workflow module on it. If you want to access the variable, access whatever variable you are using to set it.
If you're talking about from an external or cgi task, then you can use the workflow module to get the value of the variable.
~Jeff
John742
Maybe I am making this overly complex.
This is what I have for workflow variables:
<variables>
<variable key="time" value="default"/>
</variables>
I know how to grab this in an external task, but I want to be able to access this to use in the workflow. Like if I wanted to insert this variable as the description of a task. I though I could just use __INSERT__ ('time'), but this does not seem to be the case. I cannot any examples in the documentation to show how to do this.
J Dagenhardt
jbonifaci
If you're talking about when you're instantiating the workflow, you can not access the variable yet. Whatever you are using to populate time with default, you have to use that perl variable. So if you have a perl variable called $timeValue that you are using to set the variable time with, you would then have to use that same perl variable in any other place in the workflow template. The job variable does not exist until the workflow is instantiated. If you are just hard coding time to default, then either hard code it everywhere or create a variable with default hard coded and use that variable everywhere.
~Jeff
John742
I have a CGI task that Sets the time variable (SetVariable($name, $value); where $name=time) by using a worfklow object. This occurs after the workflow is instantiated, correct? I am aware of how to inject a perl variable into area's of the workflow, but how do I do the same kind of thing with a variable that is set in an external/CGI task?? Thanks for the help
J Dagenhardt
jbonifaci
Just access it in your external task using ->GetVariable('time');
I'm not sure where the disconnect is.
~Jeff
John742
Sorry, I must not be explaining what I want do.
This is my thinking:
1) I set an intial value for the time variable in the worfklow
2) I alter the value of the time variable in the CGI task
3) I insert the value for time that was changed by the CGI task as the Description of another task
CGI TASK snippet:
my $name = "time";
my $value = "some value";
my $jobId = $task->GetWorkflowId();
my $job = TeamSite::WFworkflow->new($jobId);
#Set Workflow var for scheduled time
$job->SetVariable($name, $value);
WORKFLOW SNIPPET:
<workflow name = "__TAG__('wf_name');"
owner = "__TAG__('iw_user');"
creator = "__TAG__('iw_user');"
description = "__TAG__('iw_desc');">
<variables>
<variable key="time" value="default"/>
</variables>
TASK IN WORKFLOW SNIPPET:
<dummytask name = "Prod Delay"
start = "f"
description = "I WANT TO INSERT THE TIME VARIABLE VALUE HERE">
<timeout v = "__TAG__('schedule_time');">
<succ v = "Check for conflicts in integration"/>
</timeout>
</dummytask>
J Dagenhardt
jbonifaci
I think you are confused as to how the workflow template is used. Once a workflow is instantiated, the workflow template is done with and is not used any longer. If you want to change anything about the workflow after that fact, you must do so through either an externaltask or a cgitask (or manually).
So if you want to update the description of another task when that variable changes, you will need to either use TeamSite::WFtask and ->SetDescription() or the command line tool iwsettaskdescription. You would probably want to do this immediately after updating the workflow variable.
~Jeff
John742
This makes sense. With what you are saying then I do not need to pass the varaible at all but alter parts of the workflow directly from the cgtask. Thanks for the clarification!!!
J Dagenhardt
jbonifaci
That's correct. Glad we found the same page,
.
~Jeff
blacke
This was an interesting discussion and almost had me seeing the light, but I'm having problems getting it to work. I'm using TS 6.1/Sol 9. What I have is a workflow with an initial form to get user variables, one of which is called 'remote_server'. An external task is called and uses GetVariable on that variable. If the task fails, a cgi task is used to allow the user to change any of the variable values(uses GetVariables to initialize the fields and SetVariable to set them) and when it is resubmitted, the original external task is called again. This can be reiterated until the external job passes or the user stops it. The problem is that any changes to the cgi fields are not reflected in the external task, but if I get the cgi form again, it has the new values.
My original thought was that the names are different, but they are the same throughout.
OOPs. Found the problem. I was using 'task' SetVariable rather than 'job' SetVariable. Now it's working. I wonder why there is both...
Eric
Adam Stoller
TeamSite:WFworkflow::xxxVariable are for setting / getting global job variables
TeamSite::WFtask::xxxVariable are for setting / getting task-specific variables
That's why there are both.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Bhargav Coca
I have similar issue on TS6.7.1 on Linux
I have a Variable set on my Job Instantiation screen as follows. I am trying to set this value in the Workflow as a workflow variable
TAG_info(
"macaroni" =>
[ html => $macaroni_html,
is_required => 'false',
error_msg => $localizer->format('submit_comment_error_msg'),
label => 'macaroni',
],
so if i want to define this variable everywhere in the workflow and want to have this visible in my workflow tab as a Job variable, so i have defined this on each task in my workflow as follows, but some how the varaible is still not visible
[html]
owner="__TAG__('iw_user');"
creator="__TAG__('iw_user');"
description="__TAG__('iw_submit_comment');"
verticals="__TAG__(macaroni);">
start='t'
owner="__TAG__('iw_user');"
description="My Workflow Task"
macaroni="__TAG__('macaroni');">
[/html]
I guess i have to resent to calling a ipl in an external task and set the varable, but my question is how do i get the varaible selected from Job Instantiation screen and set it in my ipl?
Can i do this?
CGI TASK snippet:
my $name = "macaroni";
my $value = "macaroni";
my $job_id = $ARGV[0];
my $task_id = $ARGV[1];
my $areavpath = $ARGV[2];
my $job = TeamSite::WFworkflow->new($job_Id);
#Set Workflow var for scheduled time
$job->SetVariable($name, $value);
How do i get value set on Job Instantiation screen into the ipl and set it to a variable inside ipl?
Thank You