Created
March 11, 2022 12:31
-
-
Save winn/0c4fbfa85de4f0b89a2ca4b151ca92e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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