I have a PHP form where users enter some data. The form then pulls additional data from the backend database and submits it all to a Google Apps Script. Amongst other things, the Google script creates and auto-populates a new Google Sheet. I would like the script to return some HTML so that the user can click on the link and access the Google sheet. However, whenever I try and generate the HTML, I always get left with a blank box:
Here is the relevant code from the Google script:
var htmlLinkToFile = "<p>The form is ready and can be accessed here: <a href=\"" + newFileUrl + "\">" + newFileUrl + "</a></p>";
var output = HtmlService.createHtmlOutput();
output.setContent(htmlLinkToFile);
return HtmlService.createHtmlOutput(output);
I have tried this version, and omitting the middle two lines and directly returning htmlLinkToFile but I keep getting the same result. If I just return the content using
return ContentService.createTextOutput(newFileUrl);
I can view the URL to the file, but obviously I would like to be able to click through.
In case it matters, here is the relevant PHP code as well:
$url = curl_init("https://script.google.com/macros/s/MYSCRIPT/exec");
curl_setopt($url, CURLOPT_POST, 1);
curl_setopt($url, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($url);
curl_close($url);
Grateful for any advice.
