Hi everyone!
I'm developing an app that saves and store data into a google sheet. I used apps scripts to retrieve, save and download the sheet as pdf. I connected the functions of apps script to App inventor, retrieve and save data functions works fine, but when I want to execute the function (getpdf) in app inventor it doesn't work, I don't know what I'm doing wrong. I'm not expert in apps script I just copied and modify some codes that I found in web.
Hi, my spreadsheet is anyone with the link can edit. The script is deploy as web app (anyone, even anonymous). The script works fine when I excecute form the script editor in google sheet. When I put the link on the browser like this --> https://script.google.com/macros/s/XXXXXX/exec?/id=XXXXX&sh=Factura&func=getpdf
the page shows an error: “The script completed but did not return anything
The reason I ask is that if "anyone with the link" you can build your pdf download url in the app within a web component, and save the file to the device. This may not be what you want because after creating the pdf you then save it to google drive ?
There are a couple of issues with your script that could be affecting the success of the web app. I will need to run a test on a script and sheet of my own.
As far as you know, is the pdf not being created at all?
Thanks TIMAI2. Yeah, I want to save the pdf in Google Drive, not in the device. By the other hand, when I run the blocks in app inventor, the pdf is not created, but when I run from scipt editor it works fine, it saves the pdf in GDrive.
Ah, this is because getPDF() is only a function and won't work as it is in a web app. Web apps must have a doGet() or doPost() function in order to work and must also return something, e.g. text/message.
It is not too difficult to convert what you have:
In your script...
Change function getpdf() to function doGet()
Before the closing curly brace } at the end of the script add a return, to start with something like: return ContentService.createTextOutput('PDF Created');
Save the script and re-publish to a new version.
In your app:
You only need to send the script url because everything is hard coded into the script.
In when Web4.GotText set responseContent to a Label so you can see what the script is returning. If you get PDF created then it is job done.