How do I add a related module in a pdf template

Hello,
I have added a one to many relationship to products from the tasks module. This is for a scenario where I am tracking the spares used in a task. My problem is when I create a PDF template to create a report of the work done I am not able to add the product list. Is there a way to do this? Alternatively is there a way for a relate to allow multiple values

Hello Vibha,

can you elaborate on the business case a bit?
Spares are just products and you don’t have to track any stock levels?
And you want to report / PDF for one task, which products have been used / related?

Basically, you’re trying to do something similar with tasks, which is implemented in the quotations and invoices?
Those use a sub-module ‘Line Items’ to build this up and that works inside the PDF templates as well.
There is quite a bit of custom code for those two modules.

Do you try to use code to get to your solution or the UI / studio / etc.?

You’ve created a 1:n relationship, so you already have multiple products allowed in the tasks (a subpanel)?

So I don’t really need line items- the purpose of this module is to track spares and activities in a service visit (this is a field service use case for specialized equipment) - I am not looking to track price here. So I repurposed tasks for a visit and I have added a 1-n relationship to products to track the spares used. Ideally this should be a field and not a relationship but I took the easy way here. Now the challenge is the engineer generates a service report when he finishes a visit and I want to list the spares used here. But with just a relationship, the product fields do not appear in the PDF template module

I see.

There seems to be some special code for makeing PDF Templates work with related modules in the case of quotes / invoices for instance.

There are some add-ons which might be able to help, or replicate the standard code from invoices and bend it to your needs.

See this post as well:

A no code idea:
You could try to write all the product names into one text-area field via workflows and calculated fields (depending on your trigger and requirements).

If you’re familiar with logic hooks, it might even be much easier to do this via PHP code (though you need to add this one additional unstructured text-field in the tasks to hold the products data).
It seems to be a technical workaround, but most likely way faster than working on the PDF template logic.

Thank you !I like the logic hooks solution- it works very well. I really appreciate it!

Glad that it worked out.

Could you please share you solution here, so it will help others?

It’s not as clean, but very easy (compared to developing PDF template code):

You’ve got module a with field x.
Then you’d create a logic hook or workflow to copy the value of field x into your module b - field x
Then you’d simply add the PDF template to module b with the place holder: module b - field x.

The disadvantage is, that you hold duplicate data.
Since it will always be kept in sync by your workflow / logic hook, you should always have correct data there.