I have created a Survey to collect information, and also wanted to collect the Geo location data.
I then created a Google App script which I have linked to the form with a link which is clicked by the user to run after completing the survey, this then adds the geo data into the same sheet.
after the script is run google displays text saying "this app was designed by a user and not google"
my question is, how can I let the script redirect them back to the form to submit another response, or at least to another html where they can click to submit a response again?
bellow is the current code I have for the script:
Gode.GS
function doGet() {
return HtmlService.createHtmlOutputFromFile("Index");
}function getLoc(value) {
var destId = FormApp.getActiveForm().getDestinationId() ;
var ss = SpreadsheetApp.openById(destId) ;
var respSheet = ss.getSheets()[0] ;
var data = respSheet.getDataRange().getValues() ;
var headers = data[0] ;
var numColumns = headers.length ;
var numResponses = data.length;
var c=value[0]; var d=value[1];
var e=c + "," + d ;
if (respSheet.getRange(1, numColumns).getValue()=="GeoAddress") {
respSheet.getRange(numResponses,numColumns-2).setValue(Utilities.formatDate
(new Date(), "GMT+2", "dd/MM/yyyy HH:mm:ss"));
respSheet.getRange(numResponses,numColumns-1).setValue(e);
var response = Maps.newGeocoder().reverseGeocode(value[0], value[1]);
f= response.results[0].formatted_address;
respSheet.getRange(numResponses,numColumns).setValue(f);
}
else if (respSheet.getRange(1,numColumns).getValue()!="GeoAddress") {
respSheet.getRange(1,numColumns+1).setValue("GeoStamp");
respSheet.getRange(1,numColumns+2).setValue("GeoCode");
respSheet.getRange(1,numColumns+3).setValue("GeoAddress");
}
}
Index.html
<!DOCTYPE html>
<html>
<script>
(function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
}
})()
function showPosition(position){
var a= position.coords.latitude;
var b= position.coords.longitude;
var c=[a,b]
getPos(c)
function getPos(value){
google.script.run.getLoc(value);
}
}
/script>
</html>
The script is running and collecting the data. I just want to add a clickable link to display to the users to submit another response, or even redirect them automatically to the same form
Would really appreciate advice on the next step!