Skip to content

Instantly share code, notes, and snippets.

@winn
Created March 11, 2022 12:31
Show Gist options
  • Save winn/0c4fbfa85de4f0b89a2ca4b151ca92e5 to your computer and use it in GitHub Desktop.
Save winn/0c4fbfa85de4f0b89a2ca4b151ca92e5 to your computer and use it in GitHub Desktop.
function doGet(request){
// Change Spread Sheet url
var ss = SpreadsheetApp.openByUrl("sheeturl");
var cid = request.parameter.customer_id
//var cid = 'U29aea6de153dac793b42dd0659e2f878'
var cidsum = finduser(ss,cid)
result = {}
result.customer_id = cid
result.totalsum = cidsum
//console.log(result)
var result = JSON.stringify(result);
return ContentService.createTextOutput(result).setMimeType(ContentService.MimeType.JSON);
}
function finduser(ss,cid){
// Change Spread Sheet url
var sheet = ss.getSheetByName('Sheet2');
var values = sheet.getRange(1,1,sheet.getLastRow()).getValues();
// console.log(values)
var ind;
for(i = 0; i < values.length; ++i) {
if(values[i][0] == cid) {
ind = values[i][0];
break;
}
}
//console.log(i)
score = sheet.getRange(i+1,2).getValue();
//console.log(score)
return score
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment