Ezra Epriputra

unread,
Mar 19, 2019, 7:26:52 AM3/19/19
to MIT App Inventor Forum
i want to make app inventor as input date range in my spreadsheet, so i can viewing some data table with that date range

anybody have googscript function for update static only 2 cells (let say A2 dan C2 cells) in one sheet?

please let me know it, because i already search but its always base on google form submit and making new rows

thanks for your att.

TimAI2

unread,
Mar 19, 2019, 7:33:24 AM3/19/19
to MIT App Inventor Forum
Have a look at this howto. Not all of it is applicable to your case, but certainly using the web app for the updating of a single cell part is


Ezra Epriputra

unread,
Mar 19, 2019, 7:59:28 AM3/19/19
to MIT App Inventor Forum
i take this script from the link that you give me..

//for testing with PC browser
function doGet(e) { 
  var ss = SpreadsheetApp.getActive();
  var sheet = ss.getSheets()[2]; 
  var id = e.parameter.id
  sheet.clearContents();
  sheet.appendRow([id]);
  var output = sheet.getDataRange().getDisplayValues();
  return ContentService.createTextOutput(output[0][0]);
}

but its error in line 5, which one should i change ?

TimAI2

unread,
Mar 19, 2019, 9:51:53 AM3/19/19
to MIT App Inventor Forum
Do you mean this line: var id = e.parameter.id ;

What does the url you run look like ?

Should have something like "?id=***** " at the end

TimAI2

unread,
Mar 19, 2019, 9:55:15 AM3/19/19
to MIT App Inventor Forum
Oh, and you have published the script as a web app and got the link for it ?

Ezra Epriputra

unread,
Mar 19, 2019, 10:50:57 AM3/19/19
to MIT App Inventor Forum

TimAI2

unread,
Mar 19, 2019, 11:03:01 AM3/19/19
to MIT App Inventor Forum
I just ran it, line 5 is 

sheet.clearContents();

which probably means

var sheet = ss.getSheets()[2];  is wrong

Sheets are counted from 0, from the left
So if "Testing" is the first sheet, change line 3 to
var sheet = ss.getSheets()[0];

So if "Testing" is the second sheet, change line 3 to
var sheet = ss.getSheets()[1];

If you are following the example I gave, your url you post in a browser should be:

Ezra Epriputra

unread,
Mar 19, 2019, 11:26:51 AM3/19/19
to MIT App Inventor Forum
It's work...thank you...

but how if i want 2 cell to change? what should i add in that script?

TimAI2

unread,
Mar 19, 2019, 11:42:21 AM3/19/19
to MIT App Inventor Forum
To keep it simple, let us assume you want data in the first and second columns

Col A = id
Col B = name

Script:

//for testing with PC browser
function doGet(e) { 
  var ss = SpreadsheetApp.getActive();
  var sheet = ss.getSheets()[2]; 
  var id = e.parameter.id ; 
  var id = e.parameter.name ;                           // add this line 
  sheet.clearContents();
  sheet.appendRow([id,name]);                           // change this line
  var output = sheet.getDataRange().getDisplayValues();
  return ContentService.createTextOutput(output[0][0] + " " + output[0][1]); // change this line (not tested but should return both ?)
}

If you want your second value in another column say Column D:

Col A = id
Col D = name

then change this line like so:

  sheet.appendRow([id,"","",name]);

That should do it ?

TimAI2

unread,
Mar 19, 2019, 11:44:50 AM3/19/19
to MIT App Inventor Forum
Oh, and your browser url would look like this:

Don't forget to make a new version of the web app, for the script changes to take...

Ezra Epriputra

unread,
Mar 19, 2019, 11:22:53 PM3/19/19
to MIT App Inventor Forum
Thanks...its work with me....

do you have tutorail how to set label to the date day before? and when the day change its automatic change?
Reply all
Reply to author
Forward
0 new messages