Generate docx from template - Custom Widget

Hi, I integrated docxtemplater into a custom widget.
docxtemplater generates reports and documents from template with {tags}. It handles conditions, loops, and has some other features. Grist is so powerful that it allows us to provide deeply nested tables in docxtemplater as is! :smiley: This is achieved using RECORD function.
Example: Docx generator example - Grist


So cool. Thank you for sharing! :raised_hands:

Hi !

Great news…
Sorry I think I made your public document buggy, wanted to see the source code to understand but it seems it has broke something :astonished:


Hi, @Sylvain_Page. No, my public document works :slightly_smiling_face:

Widget source code:

1 Like

Hi yes I’ve made some test that’s great !

(would be nice to able to incorporate image fro grist but that’s another story… :slight_smile: )
I was speaking about your grist site example, it which was down yetserday but it seems ok this morning.

1 Like

Hi @stan-donarise ,

It seems your document is not wotking at this moment.
I had some issue with mine so decided to test your public document above.
Here is what I get (Chrome/Guest)

On Firefox/logged-in , it get working… neverending with the following error in the console

Do you have any idea what causes this issue ?

Thanks :slight_smile:

Hi again,

It is now working well as well as mine …
:face_with_raised_eyebrow: :face_with_raised_eyebrow:

Hi. Checked the demo and it’s awesome. I take it that it’s not available as a free widget for Grist?

Hello. It’s available. Create a custom widget for the table, and then set
Custom URL:
Access Level: Full document access
Input: some column containing an object with keys “tags”, “name”, “attachmentId”.
For attachementId and other possible questions see Docx generator example - Grist

Thank you very much. It’s awesome.

Input: some column containing an object with keys “tags”, “name”, “attachmentId”.

with object, you mean a formula?

Not a really a question about the Grist Docx Generator, but I can´t really check how you did it because the permissions mean its all light grayed out

Yes, this column should have a formula that returns an object. You can click the “Share” button in the header and “Work on a copy” and then you can edit it.

When you talk about “object”, are you talking about a Python object or something?

“RECORD(Classes_summary_Semester.all, False, 3)”

RECORD (record_or_list, dates_as_iso=False, expand_refs=0)

So in your example, what is Classes_summary_Semester? Is it a python object? Is it a reference to a Summary Widget?

I tried doing the reference to a similar Widget I created in my app… but got an error (You can see at the bottom of the page the Summary Widget)

Yes, a Python object.

It seems you did it right. Usualy tableId for summary table looks like yours (TableForSummary_summary_ByColumn).
But for some reason this is not true for your summary table. So go to Raw Data and check what tableId your summary table has.

Ok… Grist is very specific about caps letters… it was ITPEtapas, not ITPETAPAS

The error changed now

I tried reducing 3 to 2 or 1… didn´t work.

Just for info… this is the list of Work Instructions (Instruções de Trabalho in Portuguese, that’s why IT)

And here are the steps of each work instruction.

And this is somewhat what I want… to print the steps of the Work Instruction, (step number, who does it, type of step, description and photos)

You have to upload the docx file to the cell (column “template”).
As far as I can see, the file is not loaded.

Oh, I thought the docx was generated when clicking the blue botton.

I’m having this same issue at the moment. Is it a server outage or something?


Yes I think it is a docxtemplater issue or maybe a way to restrict free version ?
I am producing for the my own docs with html but I must admit for simple case it is for easier with docxtemplater.