Home
TeamSite
Getting Workflow ID within WFT file
System
Hi,
Is there any way to access the current worflow ID within WFT file?
I have a parent workflow where an external task creates a XMJ job specification file to be used later by wftask element as nested workflow. Now to provide an unique name to the job specification file for the nested WF I am saving the file as parent jobid.XML. That way for each workflow instance I have a unique named job specification file for the child workflow.
Now the problem is knowing which file to execute from wftask element of the parent workflow. To know this I must know the current job id of the main workflow within its WFT file. Is there any way to access the current jobid value within WFT file?
Thanks for your suggestion.
-PB
Find more posts tagged with
Comments
Migrateduser
You can't modify the <wftfile> tag's "v" attribute on the fly, so you're pretty much screwed if you want to create the name of the job spec on the fly. You don't know the job ID until after the parent job is istantiated. It's a catch-22.
Dave Smith
Sr. Software Engineer
Nike, Inc.
(503) 671-4238
DavidH.Smith@nike.com
Adam Stoller
As Smitty indicated - and I believe him to be correct - you cannot change the value used for the wfttask on the fly.
However, the externaltask that you use to create the wftfile could set a job variable to the value of the jobid if you wanted...
Are you creating a WFT file - or a job-specification file (pure XML - no TAG_Info, no perl, etc.)? If the latter - you could do the entire thing in an externaltask where you create the job description file, and invoke it using iwjobc -i (one of the things you'd want to include in the generated job spec would be a job variable pointing to the parent job and perhaps another pointing to the current taskid as well) - then your child job can do what it's going to do and before it ends, do a callback to the parent job's task.
(Once the child job is instantiated - you no longer need to keep the job description file around - unless you want it for debugging purposes)
Note - the owner of the externaltask in this case (using iwjobc) must be a member of the Master role in order for iwjobc to function.
(this is the way we used to do nested jobs before the wfttask existed)
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Edited by ghoti on 07/19/04 01:57 PM (server time).
Migrateduser
Thanks for the suggestion.
Yes I am creting a job specification file (pure XML) from an external task.
I can set a parent WF variable with the jobid from my external task script but the question is how can I use that variable in the <WFtask> element to provide value (path) for <jobfile> element?
For example if I create a hidden WF variable in Tag_info section like iw_setwfarg_jobid
and then from my external task script I set that variable like
my $jobId = ARGV[0];
my $job = TeamSite::WFworkflow->new($jobId);
$job->SetVariable("jobid", $jobId);
now back in my parent wft file in the <wftask> if I use something like
<jobfile v ='$iwhome/local/config/wft/custom/__VALUE__("jobid");'/>
it doesn't work as __VALUE__("jobid") always evaluates to value of the variable at the time of instantiation that is blank.
The other alternative option I am thinking is to store value of now() in the workflow variable say jobid. So that this variable always provides an unique number. But I am not sure if this can be done in a WFT file. If this is do able could you suggest me how!!
I have also explored the option of creating the nested WF ID and invoke it using iwjobc and iwinvokejob. But landing into some trouble returning back to parent task even after a CallBack.
Thanks
Adam Stoller
Using date/time is trivial - do something like this in your wft:
<template_script><[CDATA[
#...
my $timestring = time;
#...
]]></template_script>
<!-- ... -->
<variables>
<variable key="timestring" value="__INSERT__($timestring);"/>
</variables>
<!-- ... -->
have also explored the option of creating the nested WF ID and invoke it using iwjobc and iwinvokejob. But landing into some trouble returning back to parent task even after a CallBack.
If you want to go this route and are still having problems - provide more details about how you tried to do it and we'll see if we can assist.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
formatting.rptdesign
result.zip
Migrateduser
Thanks for this.
Actually figured out the timestamp option earlier and it is working fine.
Thanks for all your help.
-PB