Best answer

How to create a Google Docs invoice from a Google Docs Template, with Line Items or Looping?

  • 4 December 2021
  • 10 replies
  • 498 views

Userlevel 1
Badge

Hi, Google Docs allows {{viarable}} to fill a template.

So how can I create an invoice from a form service (like Cognitoforms)? 

Knowing that an invoice randomly requires one or more lines…

How to use Line Items or Looping by Zapier to fill a {{viarable}} field with several values?  
 

Thanks for your help!

 

icon

Best answer by Troy Tessalone 7 December 2021, 16:09

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

10 replies

Userlevel 7
Badge +14

Hi @Schizzo 

Cognito Forms has native functionality for this: https://www.cognitoforms.com/support/69/document-merging/customizing-documents

Userlevel 7
Badge +14

@Schizzo

If you’re trying to use GDocs Templates, the try a combo of Looping and Digest.

Looping: https://zapier.com/apps/looping/help

Digest: https://zapier.com/apps/digest/help

 

Otherwise, a Code step can do this data prep for line items: https://zapier.com/apps/code/help

Userlevel 1
Badge

Hi @Troy Tessalone.

Thank’s for your quick reply.

I already use Cognitoforms custom templates, but they cost $4/month each.

I'll give it a try with Digest and Looping, and keep you posted if it works for me.

Thanks again!

Userlevel 1
Badge

Hey @Troy Tessalone, thanks for your help; but it doesn't work for me, due to formatting in Digest.

And of having to create a new Digest each time.

So I tried adding HTML to GDocs with Looping, but there are bugs: Looping doesn’t add all occurrences of text (maybe Looping is too fast for GDocs).

Also, GDocs only offers variables like {{variable}}. Is this the main problem to Loop?

I am not losing hope of success, do you have any other ideas?

Regards, Schizzo

Userlevel 7
Badge +14

@Schizzo 

You don’t need to add a new Digest each time.

You can reuse the same Digest by appending then releasing. (see screenshots)

In Digest you can use HTML to format the entries since GDocs accepts HTML.

So you’d use Looping to add all rows to the Digest then after the last iteration you’d add a Filter to continue the Zap to then release the Digest and map that to the 1 variable in the GDoc template.

 

You might want to add a Delay After Queue step to the Zaps: https://zapier.com/help/create/customize/add-delays-to-zaps

 

How do I stop a loop from running in subsequent action steps?

All actions after the looping step will run for each iteration of the loop. If you don’t want an action step to loop:

  • After the last step you want to loop, add a filter step.
  • Set the filter to only continue if the value loop_iteration_is_last matches the (Boolean) Is True condition.

The filter will run in every loop but will only pass in the last loop. Any actions step after the filter will run once in the last loop and use only 1 task.

Userlevel 1
Badge

Thank you so much, it works almost perfectly!

 

Is it possible that there are still bugs when using Looping? Because the Filter step doesn’t always work.

With the step:

  • After the last step you want to loop, add a filter step.
  • Set the filter to only continue if the value loop_iteration_is_last matches the (Boolean) Is True condition.

Sometimes it works, sometimes it doesn't:

 

Is there a solution to fix it?

Anyway, thank you very much @Troy Tessalone 🙂

Userlevel 7
Badge +14

@Schizzo 

Best to view the Zap Runs details to see the data IN/OUT for each Zap step and how each Zap step processed.

NOTE: Notice the similar timestamps and the number of Tasks used: 3 vs 6

The screenshot example below means there were 4 loops.

From what I can see the Looping is working as expected.

Make sure to check your output in the GDoc as well to verify the results.

 

Userlevel 1
Badge

Ok, now I understand Zapier's task management for Looping!

To summarize: it works with the GDocs action "Create document from TEXT", but not with the GDocs action "Create document from TEMPLATE":

VS

 

It looks like that from a TEMPLATE, GDocs doesn’t accept HTML.

And if I have to create my whole document in HTML, I no longer need a GDocs Template...

The question now is can we create an A4 document in HTML without using CSS...

Thanks again @Troy Tessalone, I'll be successful soon!

 

Userlevel 7
Badge +14

@Schizzo 

You may want to open a ticket with Zapier Support to get their feedback about whether the GDoc Template Zap action support HTML: https://zapier.com/app/get-help

 

What if you tried these Zap steps…

Action: GDocs - Create Doc from Template

Action: GDocs - Append Text to Document (HTML from Digest)

 

Otherwise, this solution may require using the GDoc API: https://developers.google.com/docs/api

App APIs can be used in Zaps with the Webhooks app: https://zapier.com/apps/webhook/help

Userlevel 1
Badge

Ok @Troy Tessalone I will open a ticket, and try your suggestion.
Thanks again for all your help 🙂