I intend to send the data in the form where the 2 first entry will be static during the post and the 2 second part will be dynamic.
As per code below:
var name = e.parameter.name
var age = e.parameter.age
var P1 = e.parameter.P1 ;
var F1 = e.parameter.F1 ;
var P2 = e.parameter.P2 ;
var F2 = e.parameter.F2 ;
if(name)sheet.appendRow([name,age,P1,F1]);
if(name)sheet.appendRow([name,age,P2,F2]);
Expected result
name
age
P
F
Doe, John
25
horse
tools
Doe, John
25
hammer
animal
The way that you shared is very helpful but will allow me to only append the whole row.
In terms of blocks, how can I post data in one shot where it will pass through the app script to get the expected result?
function doPost(e) {
var data = JSON.parse(e.postData.contents) ;
var ss = SpreadsheetApp.getActive(); //assumes script bound to spreadsheet
var sh = ss.getSheetByName('Sheet1');
for (var i=0;i<data.length;i++) {
sh.appendRow(data[i]);
}
return ContentService.createTextOutput("Success") ;
}