Exclude Blank QuestionPro Survey Answers in Generated Google Doc

  • 11 July 2022
  • 0 replies
  • 8 views

So in my other post I described how I set up a zap which creates a Google Doc from a QuestionPro response which includes the image of the signature by using HTML. 

 

The next problem I ran into was that 2 questions in the survey were formatted as tables and particularly long. They wasted a lot of space in the survey response document that was created when they were blank. So I needed to figure out a way to exclude or remove these questions from the response document when they were blank so the document was shorter. I am a beginner, but I thought I would include the steps I went through in case they are of any help. They may not be the most efficient way of accomplishing my goals.

 

Try Number 1: The key words here are “exclude” or “remove.” I started by trying to figure out how I might remove that section of the html if the responses to those questions were blank. I intended to use Zapier formatting to find and remove the html for the blank questions after applying a filter that tests whether a certain part of the table had been completed. 

PROBLEM: I couldn’t even start on this because I couldn’t find a zap that properly pulled the HTML I originally added. I couldn’t figure out a way to access the HTML from the Google Doc action step. The output from the Google Doc step creating a document didn't include the HTML. I tried using a WebHook Get zap to pull the HTML from the Google Doc, but once the HTML was added to the Google Doc, it added paragraphs of additional HTML which complicated what I was trying to edit. I could use more Zapier formatting steps to pull that off, but that becomes more complicated and adds more steps than necessary. There may be a way to write the HTML code in a zap that is more accessible. I do not know.

 

Try Number 2: Next I thought I would just add a step that appended the Google Doc with the questions if they were answered. I could use a filter before the append document step, that way if they were blank, the questions wouldn’t be included and the survey response would be shorter. I was worried that appended HTML would not be rendered, but I was pleasantly surprised to discover that it worked and was formatted the way I wanted. 

PROBLEM: While this technically worked, it made the survey response document awkwardly formatted. If those questions were answered, and thus appended, they could only be added to the end. Because we had a signature, this meant that these two questions would be included after the signature and not look great. 

 

Try Number 3 (Success): I decided to approach it in a different way and instead of editing the HTML text after it was created, I would change what HTML was created based on the survey responses. After the QuestionPro trigger, I created 2 paths, with another 4 nested paths in each one. So I had to write different HTML codes for each of the 8 possibilities. The 2 paths determined whether one of the tables would be filled out or left blank based on a previous question. The 2 paths used the “Text Does Not Contain” function to determine how the question would be answered. If answer “B” was chosen, then it would go on path 1 which included the table (let’s call it Apple table), if answer “B” was not chosen, then it would go on path 2 which did not include the Apple table. 

 

Now within path 1 and 2, I had 4 nested paths. All 4 nested paths in path 1 would include the Apple table. All 4 nested paths in path 2 would NOT include the Apple table. 

 

The reason I used 4 separate nested paths is because the second table, let’s call it Orange table, would always be filled out, but would have a different number of table cells filled out each time and I needed a way to reduce the number of table cells included in the final survey response document so it only showed those that were filled out. I decided it was simplest to deal with it in rows. Orange table was 3 columns by 5 rows in total. I had each nested path check the response of the last column in the row to see if there was an answer, and check the first column in the next row to see if it was blank, then generate the HTML with the corresponding number of rows. 

The first nested path checked column 1, row 2 and if it was blank, it would move on to the HTML Google Doc Creation step where the Orange table only showed row 1. 

The second nested path checked column 1, row 2 to see if it had an answer, AND checked column 1, row 3 to see if it was blank. If both of these were true, it meant that there were answers in row 1 and row 2, but not row 3 so only 2 rows should show in the HTML. So it would move on to the Google Doc creation step with HTML that only showed rows 1 and 2. 

This continued, so I have HTML created which shows the Apple table and Orange table with 1 row, the Apply table and Orange table with 2 rows, etc.

 

 

Once again, not sure this is the best way, but it is the cleanest way that I could figure out.


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