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)
Retrieve task id from within presentation template
disco
Does anyone know how to retrieve the current task or job id from within a presentation template? I'm calling iwpt_compile.ipl from an external task and I know that I can just pass the task id as a argument into iwpt_compile.ipl. I'm just wondering if I can get it without having to do this.
Find more posts tagged with
Comments
Adam Stoller
I don't believe that the taskid information is passed through iwpt_compile.ipl to the DCT/DCR/PT automagically - so I think you'll have to pass it in as a parameter yourself.
Out of curiosity - for what reason are you attempting to access this information within the PT?
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
aaaa Streamserve Extract.pdf
Migrateduser
Assuming that the file is already attached to the job I think you could use iwgetfilejobs without custom command line parameters to iwpt_compile.ipl. And/or use an environment variable.
disco
I'm writing a class (TCPL::Log) that will take care of all logging for all perl in external scripts, presentation templates, workflow config files etc.....
The class will create one log file for each job. The log files will be organized by branch and named according to workflow name and jobid. All tasks in the job will write to that log file. In order for this to work, each TCPL::Log object needs to know what job it belongs too. For that reason, I need to pass the task or job id into the constructor for TCPL::Log. So, any perl code that wants to instantiate this class will have to know its task or job id.
Any thoughts you have on this are welcome.
Thanks
Adam Stoller
We did something similar at my customer, but we log everything into one log file (that gets rotated nightly) - when there is a task object available (optional second parameter) we include job/task information in the log output. Where we didn't have a task object available (such as in generating pages) the data still gets logged but there's no job/task information. We though about passing an arbitrary data object as a parameter - but that still wouldn't solve this problem until/unless you manage to pass the task object (or taskid from which you could create the task object) into the page generation process.
I think either passing it in as a parameter or, as was suggested, using iwgetfilejobs on the DCR from which you're generating the page is the only reasonable way to do it. The more I think about it - the iwgetfilejobs solution sounds like a pretty good solution (expensive, because it requires invoking an additional process to run the CLT, but ..)
It would probably make a nice enhancement request to allow internal passing of the taskid into the process - with maybe an additional flag to both iwgen and iwpt_compile.ipl (and iwregen).
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
disco
I don't currently have the tpl file attached to the job. It is only passed as a parameter to the iwpt_compile.ipl command. I don't think I want to add it to the job as that would result in the file getting submitted during the submit task.
It seems that passing the task id into iwpt_compile.ipl is the only other option so I'll go ahead with that.
Thanks very much for your help,
dh
Migrateduser
I don't mean that the TPL that you are generating with should be attached to the job - I mean that if the DCR and/or output file(s) are attached to the job (preferably the DCR), since that is already passed to iwpt_compile.ipl you could get it from the command line, then use iwgetfilejobs to determine which job it is associated with. This would break if the file could be associated with more than one job.
I would still avoid custom command line parameters - have your externaltask script define an environment variable based on the Task ID or Job ID, and your TPL could reference that.