PDF Generation - Google Scripts help

Evening all.

Something came up in a thread the other week which prompted me to find this. Full disclosure - I am utterly useless with coding, so was wondering if anyone knew if it was possible to trigger the PDF Creator from a new row being added to the sheet using script?

If that is possible, I think that it should be able to create a PDF copy of the form people are filling in, which would be awesome. If not, back to the drawing board.

4 Likes

I used the same resource page to use a script to create a PDF from a named range with a specific name from a cell in the spreadsheet at saved in a folder. I am likely more code-useless, was not sure I could get it to work, but it does.

Would have to ask @Darren_Murphy for this. I have a brief look at the link and seems like the author used a “.onFormSubmit()” line, would it be possible for us to change it to something like “.onChange()” and set an on change trigger Darren?

2 Likes

Yes, that should work.
But, you’d need to add some extra conditional logic to direct it when to create and send the PDF.
If you just replace the onFormSubmit() trigger with an onChange() trigger, then it will start creating a PDF every time a change is made anywhere in the spreadsheet. Which I suspect isn’t the desired behaviour :rofl:

1 Like

:rofl::rofl::rofl: Yesss I admit I forgot those conditions sometimes then a bunch of emails arrived when I test it.

1 Like

Currently is there a way to generate PDF from Glide Table? Is there any plans for that capability?

From a Glide Table?
You’d need to use an integration tool such as Zapier or Integromat.

If we are using purely Glide Table, no more Google sheets, will Zapier/Integromat still work?

That’s a good question.
I think the answer is yes, but with limitations.
For example, you could still use the Webhook Action to post to an Integromat webhook endpoint, but the options from there would be limited. Integromat cannot access the data in the Glide tables, so it could only work with whatever parameters you pass through the webhook.

2 Likes

I would be very surprised if this were the case. My coding skills are limited to

10 print “hello”
20 goto 10

That was on the BBC Micro in the late 80’s. In hindsight I should have continued developing that skill set, alas I got really good at Tetris instead.

Could I simply dump that data into a different spreadsheet altogether and use the onChange?

As you can probably tell, I like to work around my limitations.

Can you explain your use case in a little more detail?
When you say “dump that data”, I’m not really sure what you’re referring to.

The thing about an onChange() trigger is that it fires every time a change is made to the sheet it’s associated with. The original script that you posted was written to work with an onFormSubmit() event, so by default it will process the data that was submitted via the Google Form. An onChange() event has no visibility of any form data, so you need to tell it where to look.

I have an app, one part is a form that populates a sheet.

The data in this sheet isn’t needed in the app except to read the date the row was submitted and cross reference against who filled the form out, but no changes are made to the data after submitting.

The data is used externally of the app to create PDF’s.

From what you are saying the onChange would trigger when data on any sheet anywhere in the spreadsheet was updated (which would happen regularly with the app firing data here and there). I was wondering if I could send the form data to another sheet with only that data, so at that point onChange can apply to the whole spreadsheet.

Of course, there is probably a way to have it so onChange only happens when a row is added. But that would have involved me coding :rofl:

Okay, I understand.
So before I start writing some code for you (which I don’t mind doing, if it comes to that), let me ask another question…

Why not just send a webhook to Integromat, and let it do all the heavy lifting for you?

I am trying to avoid using any 3rd party services (that may end up costing) if at all possible. This app is a favour for a friend who’s company has been hit really hard by the pandemic. He currently uses some bespoke software to run his climbing gym which costs a fair chunk each month, and I am trying to replicate that with a Pro sub to glide which will be rather a lot less for him.

It has melted my brain at times, but I think I am all but there. This part involved coding, and my brain just will not go that far (damn you Tetris).

You would be a bloody legend if you could help.

I am sure something like this would be a fantastic resource for a lot of apps, as there are loads of situations where people need uneditable (PDF) copies of filled out forms.

Integromat have a very generous free tier, I’d really encourage you to take a look before ruling it out.

If you can give me access to an (editable) copy of your sheet, I’ll take a look (PM me if you want).

1 Like

cough Document Studio cough

https://workspace.google.com/marketplace/app/document_studio/429444628321

1 Like

Looks like it would do most of what I need it to when combined with the merge every hour. My only concern is that if it stops working, it isn’t something that is under our control to fix.

1 Like

try this: click the link below, click “offer price / reserve”, add comment “just testing” , submit, wait 10-20 seconds…
check your email and PDF attachment…
and see magic happen :wink:

Hi Uzo, can give some hints on how to do it?

Curious to see how this works. I didn’t get an email though after I did the process above. I put “just testing” in the required name field then hit submit. It’s been about 30 minutes and I haven’t received an email yet.