Best answer

How can I append dynamic HTML-coded text to a table in a Word document using Zapier?

  • 7 November 2023
  • 8 replies
  • 282 views

Userlevel 1

Hello,

 

I am currently setting up a Zap with a loop that finds strings of text, searches against entries in an Excel table and returns a column from that table. Everything here works fine,

 

The problem I am having is that I want to add this text to a table, which I don’t know the size of - the number of rows depends on the number of successful searches. I add the text using Append text to Document, but however I try to split the table, it doesn’t insert the text inside the table, but rather below as plain text… Is there a way I can store the html-coded text, add the additional codes on each success of the loop and then in the end append the whole html-coded table to the word document, so that it’s in the table?

Here is some more info along with my code (don’t mind it as syntax, it works :D):

 

<table style="float: left;width:600.25pt;background:#FFC000;border-collapse:collapse;border:none;margin-left:6.75pt;margin-right: 6.75pt;">
    <tbody>
        <tr>
            <td style="width: 260.85pt;border: 1pt solid windowtext;padding: 0cm 5.4pt;height: 17.7pt;vertical-align: top;">
                <p style='margin:0cm;margin-bottom:.0001pt;line-height:106%;font-size:15px;font-family:"Arial",sans-serif;margin-top:2.85pt;margin-right:44.25pt;margin-left:0cm;'><strong><span style='font-family:"Cambria",serif;color:#4A442A;'>To Consider</span></strong></p>
            </td>
            <td style="width: 339.4pt;border-top: 1pt solid windowtext;border-right: 1pt solid windowtext;border-bottom: 1pt solid windowtext;border-image: initial;border-left: none;background: rgb(146, 208, 80);padding: 0cm 5.4pt;height: 17.7pt;vertical-align: top;">
                <p style='margin:0cm;margin-bottom:.0001pt;line-height:  106%;font-size:15px;font-family:"Arial",sans-serif;margin-top:2.85pt;margin-right:40.5pt;margin-left:0cm;text-indent:12.8pt;'><strong><span style='font-family:"Cambria",serif;color:#4A442A;'>What Does It Mean?</span></strong></p>
            </td>
        </tr>

 

 

THIS IS CREATED BEFORE THE LOOP SO THE TABLE IS MADE AND MY IDEA IS FOR EACH SUCCESSFUL FINDING TO APPEND THE NEXT SECTION:

 

 

<tr>
<td style="width: 260.85pt;border-right: 1pt solid windowtext;border-bottom: 1pt solid windowtext;border-left: 1pt solid windowtext;border-image: initial;border-top: none;padding: 0cm 5.4pt;height: 18.55pt;vertical-align: top;">
                <p style='margin:0cm;margin-bottom:.0001pt;line-height:106%;font-size:15px;font-family:"Arial",sans-serif;margin-top:2.85pt;margin-right:46.5pt;margin-left:0cm;'><span style='font-family:"Cambria",serif;'><a href="{{212226331__COL$E}}"><span style="color:white;"><b>{{212226331__COL$B}}</b></a></span></strong></a></span></p>
            </td>
            <td style="width: 339.4pt;border-top: none;border-left: none;border-bottom: 1pt solid windowtext;border-right: 1pt solid windowtext;background: rgb(146, 208, 80);padding: 0cm 5.4pt;height: 18.55pt;vertical-align: top;">
                <p style='margin:0cm;margin-bottom:.0001pt;line-height:normal;font-size:15px;font-family:"Arial",sans-serif;margin-top:.85pt;margin-right:11.5pt;margin-left:10.95pt;'align=justify><strong><span style='font-family:"Cambria",serif;'><span style="color:white;">{{212226331__COL$D}}</span></strong></p>
            </td>
        </tr>

 

HERE AFTER THE LAST ITERATION I WANT TO ADD THIS SO THE TABLE FINISHES AND I CAN ADD MORE TEXT AFTER THAT.

    </tbody>
</table>

 

Again, I don’t see it working with Append text, I have to store it somehwere as plain code and then append it at the last step. Can I make a .txt file or just string text stored, then deleted after the last step (I currently use the API call to delete files from GDrive)?

 

Any help would be great!

 

Thank you in advance :)

icon

Best answer by SamB 9 November 2023, 13:38

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.

8 replies

Userlevel 7
Badge +6

Hi there @Visa Geeza,

Before we dig deeper into this, would you mind sharing a detailed screenshot of how your Zap is configured? Also, a screenshot of the “Action” section of your action step that shows all of its fields.

46dd6c0979e3d815d621b8da43084ef1.png
(view larger)

Please don't include personal information in the screenshot, or be sure blur out any personal information.

Thanks!

Userlevel 1

Hey Ken,

 

Thank you very much for your reply! Here you go:

Zap steps:

You don’t need to care about the previous steps, they are parsing emails, formatting text etc.

The idea is to: 12) create a document from template; 13) Append some formatted text from the previous steps; 14) Create a loop that runs how many times a keyword is found; 15) Lookup these keywords against a table in our GDrive that has additional info for each keyword; 16) Append that info if the keyword is found against the Excel table - HERE IS WHERE I WANT THIS DATA TO BE ADDED AS ROWS IN A TABLE. NOT A SEPARATE TABLE; 17) continue only if this is the last loop iteration; 18) Append some more text from the parsed email; 19) send an email to the sender from the parser; 20) delete the document that has been sent.

 

Here are screenshots of the action of the Append text steps, IDK why you need them since everything in the zap itself runs fine :)

 

Cheers!

Userlevel 7
Badge +11

Hi @Visa Geeza! 👋

Hope you don’t mind me hopping in to see if I can lend a hand with this. 🙂

I wonder if it might be worth adding the different table rows data and HTML into a Digest and have the Zap release the digest on the last loop iteration, which would collate necessary table rows together. Then in the Google Docs action you’d select the “rows” digest before the closing of the surrounding table HTML tags.

You’d need a Append Entry and Schedule Digest action set to have a Frequency of Manual. In there you’d create the necessary table row HTML and data so that for each loop that runs a new set of table row HTML and data would be added to the digest.

Then, after the Filter action that checks whether it’s the last loop iteration that’s running, you’d have a Release Existing Digest action which would output the entire digest of all the table rows. Then in your Append Text to Document action you’d have the necessary closing HTML tags for the table and you’d select the output from the second digest action. For example:
049b573cfb583dee44b1428bcd496591.png

You can learn more about how to use Digest by Zapier here: Compile data in a digest in Zaps

Do you think that approach could work for this? If I’ve misunderstood what you’re looking to do here or you run into any issues on that at all just let me know! 

Userlevel 1

Hey Sam,

Thank you so much for your answer! I was looking into Digest, but didn’t think it would support this. Will try and get back here with the result.

 

Thank you very much again!!!

 

Cheers!

Userlevel 1

Hey,

 

Thank you very much!!! It works great, except for one thing - the Digest doesn’t clear out when I run the Release Existing Digest action (I am only Testing). I saw that there is no way to delete a Digest automatically after using it and I don’t want to create new ones for each time this ZAP runs. Will it clear out in Run Mode and how can I clear it in Test Mode?

 

Thank you in advance and take a bow, Sam :)

Userlevel 7
Badge +11

You are most welcome, @Visa Geeza! 🤗

When the Release Existing Digest action runs (while the Zap is switched on) it will then clear the entries in the digest so that the next time the Zap runs a new set of digest entries will be generated. 

To clear the digest when testing in the Zap Editor you can change the Title of the digest in the Append Entry and Schedule Digest action to generate a new digest. 

Hope that helps to clarify. Do let me know if I can assist with anything else - always happy to help! 🙂

Userlevel 1

Perfect! Thank you again very, very much!

Userlevel 7
Badge +11

Glad I could help, @Visa Geeza! 😁

Seems like you’re all set on this for now but please do feel free to reach back out to the Community again if you need any assistance in future. In the meantime, happy Zapping! ⚡