Issues with My Script.... Maybe

36 views
Skip to first unread message

Jason Mattson

unread,
Aug 14, 2020, 10:26:09 AM8/14/20
to Google Apps Script Community
Hello Community,

I have a Google Sheet that I wrote a lot of script for. It has been working well up until last night. The issue that we are running across is that when I Run the "Submit" function, it is supposed to save a PDF copy of the spreadsheet. As well as send the user an email with the PDF attached. What is happening now is that the function is dumping the file into HTML. Which is unusable for me and my customers. 

Has anyone else run into this issue before?
If so how do I fix it?
If not any suggestions??

I have also contacted Google to see if they have changed any script settings on their end and they say that they have not. 
I have not made any changes to the script or the spreadsheet, so I am at a major loss right now.

I have attached a folder with a copy of the spreadsheet as well as the PDF dump location "SUBMIT".
I tried to share the script but the gs.script editor is not allowing it at this time... Maybe they are having issues.

Please any assistance would be greatly appreciated!

Sincerely,
Jason Mattson
TOK Consulting LLC



Google Community Folder

Darren D'Mello

unread,
Aug 16, 2020, 3:07:14 AM8/16/20
to google-apps-sc...@googlegroups.com
You could share the sheet/code for debugging.

Also check that spreadsheet parameters to convert to PDF have changed?

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/cdecbdaa-3661-4497-8165-4f1262079edao%40googlegroups.com.


--
Best,
Darren

Michael MacKay

unread,
Aug 18, 2020, 9:18:23 PM8/18/20
to Google Apps Script Community
I just came across this exact issue a script I have been running for years. Based on your observation that it was dumping the HTML I did some digging into the URL it was using to generate the pdf and found the problem. 

I had this in my 'submit' method to get the URL:
var url = ss.getUrl();
url = url.replace(/edit$/,''); 
var url_ext = 'export?exportFormat=pdf&format=pdf'

I hadn't touched this script in years so I don't recall what the URL used to be, but notice the new URLs have additional text after the edit, for example:
/edit#gid=111111111

I changed the regex in replace() to remove 'edit' and everything after it and it works again:
var url = ss.getUrl();
url = url.replace(/edit.*$/,'');
var url_ext = 'export?exportFormat=pdf&format=pdf'

A simple `.*` fixed it....
Hope this helps.

Cheers,
Mike
Reply all
Reply to author
Forward
0 new messages