Skip to content

Instantly share code, notes, and snippets.

@IanMulvany
Created October 4, 2016 22:35
Show Gist options
  • Select an option

  • Save IanMulvany/bdfa75bc6fc895d363826295a7de2931 to your computer and use it in GitHub Desktop.

Select an option

Save IanMulvany/bdfa75bc6fc895d363826295a7de2931 to your computer and use it in GitHub Desktop.
function respondToFormSubmit(e) {
var settings = PropertiesService.getDocumentProperties();
var authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL);
// Check if the actions of the trigger require authorizations that have not
// been supplied yet -- if so, warn the active user via email (if possible).
// This check is required when using triggers with add-ons to maintain
// functional triggers.
if (authInfo.getAuthorizationStatus() ==
ScriptApp.AuthorizationStatus.REQUIRED) {
// Re-authorization is required. In this case, the user needs to be alerted
// that they need to reauthorize; the normal trigger action is not
// conducted, since authorization needs to be provided first. Send at
// most one 'Authorization Required' email a day, to avoid spamming users
// of the add-on.
sendReauthorizationRequest();
} else {
Logger.log("responded to form submit");
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var values = sheet.getDataRange().getValues()
Logger.log(values.length)
for(n=1;n<values.length+1;++n){
// var cell = values[n][3] ; // x is the index of the column starting from 0
var coordinate = "G" + n;
Logger.log(coordinate);
var cell = sheet.getRange(coordinate);
var formulat_string = '=CONCATENATE(B' + n + '," ",' + 'C' + n + ')';
cell.setFormula(formulat_string);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment