When you open a task - in the browser URL it displays the task-id for that task.
You can always get the URL prarameters in your ftl. The place to capture such request parameter would be form.lib.ftl wherein you may define a hidden field to hold the value for task id which you can use on your ftl.