Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Getting the pdf form from a task id

Avatar

Level 3

I am writing a component for getting the pdf form from a task id, I know how to get the form data(xml) from the task but how can I know which form template to use to render the it as pdf form?

0 Replies

Avatar

Level 3

Anyone know how to get the form template from a task, so I can render it as a PDF form?

Avatar

Level 3

I still can't find an answer yet, please advise if it's possible to get the form template from a task?

Avatar

Level 10

You can do that!

Use the following method to get the XML data along with the Form Template:

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData)

The above method returns a Form Instance which consists of both Form Template and XML data (only if your thrid parameter is true)

If you would like to find the template path, you can use:

 FormInstanceVariable.getTemplatePath(); 

which returns a template path string.

Here is API reference.

Nith

Avatar

Level 3

Thanks Nith.

so if I use

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData)

and set the retrieveData to true, it will return a PDF?

Avatar

Level 10

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData).getDocument();

The above code will return the PDF document.

Or if you want the XML data & template path separatelly, use the following expressions:

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData).getXFAData();

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData).getTemplatePath();

Nith

Avatar

Level 10

Sorry, a small mistake on my previous response..

The following code will return XML data and not the actual PDF! You will have to import it to the template to get the PDF result.

TaskManager.getFormInstanceForTask(long taskId, long formInstanceId, boolean retrieveData).getDocument();

Nith