Microsoft Word Template prints Make expression/JSON instead of rendered text for aggregated orders

:bullseye: What is your goal?

I want to generate a DOCX file from WooCommerce orders using the Microsoft Word (Docx‑Templater) module in Make.
For each order I build a text block (pedido_texto) with order number, customer details, address, a picking list, total, and notes.
Then I aggregate all orders into a single variable (contenido_pedidos) and insert it in the Word template using the placeholder for that variable.

:thinking: What is the problem & what have you tried?

Instead of showing the rendered text (for example Pedido #32827 and Cliente: DEBORAH TERESA VACAS LÁZARO and the picking list), the DOCX shows the raw Make expression and the JSON of the line items.
The same template and delimiters work correctly for other fields (fechainicio, fechafin, fechageneracion), so only contenido_pedidos is affected.

:clipboard: Error messages or input/output bundles

There is no explicit error message from Make; the scenario runs successfully, but the generated DOCX content is wrong.
Relevant configuration and sample outputs:

Module 18 (Tools > Set variable) – pedido_texto value (simplified):

“Pedido #” & {{3.number}} & “\n” &
"Cliente: " & {{3.shipping.first_name}} & " " & {{3.shipping.last_name}} & “\n” &
"Teléfono: " & {{3.billing.phone}} & “\n” &
"Dirección: " &
trim(
{{3.shipping.address_1}} & " " &
ifempty({{3.shipping.address_2}}; “”)
) &
“, " & {{3.shipping.postcode}} & " " & {{3.shipping.city}} &
ifempty(”, " & {{3.shipping.state}}; “”) &
“\n\n” &
“PICKING:\n” &
join(
map(
toArray({{3.line_items}});
item.quantity & " x " & item.name
);
“\n”
) &
“\n\n” &
“Total: " & {{3.total}} &
ifempty(”\nNotas: " & {{3.customer_note}}; “”) &
“\n\f”

Module 19: Basic Aggregator on module 18; output contains an array 19.array with pedido_texto for each order.

Module 20 (Tools > Set variable) – contenido_pedidos value (current version):
{{join(
map(19.array; item.pedido_texto);
“\n\n”
)}}
Module 22 (Microsoft Word > Create DOCX from template):

Values entry: key contenido_pedidos, value type Value, value {{20.contenido_pedidos}}.

In the DOCX template: placeholder {{contenido_pedidos}}.

Actual DOCX output example (simplified):

“Pedido #” & 32827 & “\n” & "Cliente: " & DEBORAH TERESA & " " & VACAS LÁZARO & “\n” & …
PICKING:
join(
map(
{“id”:302443,“name”:“Aguacate Primera”,“product_id”:4910,“variation_id”:0,“quantity”:7,…}

Instead of the expected:

Pedido #32827
Cliente: DEBORAH TERESA VACAS LÁZARO
PICKING:
7 x Aguacate Primera
1 x Caja de Naranjas (para zumo y de mesa)

:link: Create public scenario page

:camera_with_flash: Screenshots (scenario flow, module settings, errors)

1 Like

Hey there,

can you show some screenshots from the scenario and how you have the modules setup at the moment?

1 Like

Hello! Sure i just uploaded it!

And what is the iterator module iterating on?

Hello!

Iterator module is iterating over the array of orders returned by the WooCommerce API call. Its supposed to take that array and process one order per bundle:

Both, the input and output from the iterator is ok. Everything (id, first_name, etc) seems right:

The problem is at the input/output from the Tools/Set Variable Module (pedido_texto). It shows the characters issue.


I dont know if im placing the variable value of pedido_texto incorrectly. Ive tried placing the trim, ifempty, join and map in both ways, as a function and as plain text but I get the same result at the generated docx. (““, &, etc)

I also tried to place & as an And functions.

Ok so.

You don’t need array aggregator here, you need text aggregator.

Your source module is wrong, it should be the iterator, not the set variables.

What you have inside the set variables is just free text. This is why you are getting it in the document. None of those are Make functions. You need to select the functions from the menu instead and you will see the difference.

You don’t need toArray the line items, it’s already an array. And your map on top of it is wrong. What are you trying to get out of that?

Yes, thank you, you are right. Ive changed the source module to the iterator

Now the DOCX recieves the data, but not from the PICKING part (joint), instead it shows spaces as you can see in DOCX picture

Also, I have noticed that the word NOTAS: is not showing on the DOCX, only their maped 3.costumer_note data. And the structure on the DOCX is not placed in a NEW ROW as marked on the text aggregator.

Could it be a function’s sintaxis in the PICKING part or something im missing inside those functions?

Yeah that’s not how map works at all. Here.

Also your ifempty() looks strange and the Notas is inside of it. Also it will never be empty the way it is written and there is no fallback anyways. So I guess it is not needed? Or you meant to have something else there?