0% found this document useful (0 votes)
51 views1 page

Send and Read One Data

The document contains a Google Apps Script that defines two functions, doGet and doPost, both of which call ManageSheet to handle requests. The ManageSheet function processes requests to create new records in a Google Sheet or read a specific record based on parameters provided in the request. It supports creating records with name, phone number, and email, and reading a record by its ID, returning the data in a specific format.

Uploaded by

Johan Yan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views1 page

Send and Read One Data

The document contains a Google Apps Script that defines two functions, doGet and doPost, both of which call ManageSheet to handle requests. The ManageSheet function processes requests to create new records in a Google Sheet or read a specific record based on parameters provided in the request. It supports creating records with name, phone number, and email, and reading a record by its ID, returning the data in a specific format.

Uploaded by

Johan Yan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

function doGet(e) {

return ManageSheet(e);
}
function doPost(e) {
return ManageSheet(e);
}

function ManageSheet(e) {

//CREATE NEW RECORD


if (e.parameter.func == "Create") {

var ss = SpreadsheetApp.getActive();

var sh = ss.getSheets()[0];

var data =[e.parameter.Name, e.parameter.PhoneNumber,e.parameter.Gmail];

sh.appendRow(data);

return ContentService.createTextOutput("Success");

else if ( e.parameter.func == "ReadOneRecord") {


var ss = SpreadsheetApp.getActive();
var sh = ss.getSheets()[0];
var rg = sh.getDataRange().getValues();
var outString = '';
outString += rg[parseInt(e.parameter.id)].join('**');
return
ContentService.createTextOutput(outString).setMimeType(ContentService.MimeType.TEXT
);
}

You might also like