I need help i cant get it to work, sending data to spreadsheet

can someone please fix this for me?. this is an app that can send data to spreadsheet by scanning qr codes. and i want to manually input some remarks before the data is sent to spreadsheet. thankyou

please fix the button 3 for me

https://script.google.com/d/1wYVTcpfHOlykfsSJrccnCg6N8_852pW3V-gj73OqS7iUAPHxfxzBEn5v/edit?usp=drive_web

You need to show your web app script, copy and paste it here as text.

1 Like
var ss = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1irqfXS0ghkfqcduvkTQibu2wUvCQuCNIOAO9WOXCSug/edit#gid=0");
var sheet = ss.getSheetByName("C-AttendanceBETA");
var timeZone = Session.getScriptTimeZone();
date = Utilities.formatDate(new Date(), timeZone, "MM-dd-yyyy | HH:mm:ss");


function doGet(e){
  var action  = e.parameter.action;
  
  if(action == "in")
    return inTime(e);
  
    if(action == "T")
    return TTemp(e);
   
  if(action == "out")
    return outTime(e);
  
}


function doPost(e){
  var action  = e.parameter.action;
  
  if(action == "in")
    return inTime(e);
  
  if(action == "T")
    return Temp(e); 
  
  if(action == "out")
    return outTime(e);
  
}

function inTime(e){
  var id = e.parameter.id;
  var values = sheet.getRange(2,1,sheet.getLastRow(),1).getValues();
  
  for(var i = 0 ; i<values.length ; i++){
    if(values[i][0] == id){
      i=i+2;
      var in_time = Utilities.formatDate(new Date(), "GMT+8", "MM-dd-yy hh:mm");
      sheet.getRange(i,3).setValue(in_time);
      return ContentService.createTextOutput("Thank You ! Your TimeIN is "+in_time).setMimeType(ContentService.MimeType.TEXT);
    }
  }
  return ContentService.createTextOutput("Id Not Found").setMimeType(ContentService.MimeType.TEXT);
}


function outTime(e){
  var id = e.parameter.id;
  var values = sheet.getRange(2,1,sheet.getLastRow(),1).getValues();
  
  for(var i = 0 ; i<values.length ; i++){
    if(values[i][0] == id){
      i=i+2;
      var out_time = Utilities.formatDate(new Date(), "GMT+8", "MM-dd-yy hh:mm:ss");
      sheet.getRange(i,4).setValue(out_time);
      return ContentService.createTextOutput("Thank You ! Your TimeOut  "+out_time).setMimeType(ContentService.MimeType.TEXT);
    }
  }
  return ContentService.createTextOutput("Id Not Found").setMimeType(ContentService.MimeType.TEXT);
}

function TTemp(e){
  var Temp = e.parameter.Temp ;
  var values = sheet.getRange(2,1,sheet.getLastRow(),1).getValues();
  
  for(var i = 0 ; i<values.length ; i++){
    if(values[i][0] == Temp){
      i=i+2;
      var T_Temp = e.parameter.Temp; 
      sheet.getRange(i,5).setValue(T_Temp);
      return ContentService.createTextOutput("Thank You ! Your Temperature is "+Temp).setMimeType(ContentService.MimeType.TEXT);
    }
  }
  return ContentService.createTextOutput("Error").setMimeType(ContentService.MimeType.TEXT);
}

has two T's

your call has only one

Yes . I tried a single T before but still it doesnt work . I dunno what to do haha

Did you...

1 Open the script project
2 Go to Publish
3 Deploy as Web App
4 Project version: - select New from the dropdown
5 Execute the app as: your google account address (email)
6 Who has access to the app: Anyone, even anonymous
7 Press the Update button

You have to do this EVERY TIME you change your script

Yes i did. I already have 29 versions

I also see

function TTemp(e){
var Temp = e.parameter.Temp ;

You are sending &id = textbox.text

You need to send &Temp = textbox.text

I will try that. Thankyou

I need the data of texbox in the fifth row

Its not working . I think something is wrong with the blocks. I cant came up with a solution

the error message tells you that "Temp" is not defined. Check your script parameters match and ensure you update again.

The attached script works for me (well only the error messages return because I do not have your data)

script.txt (2.3 KB)

Make your Temperature PostText look like this:

You need to confirm about your " set web1 Url to .......... link as your [spreadsheet] link and join block

in a separeted post you can search for the item ID in your spreadsheet and put the extra data in the corredpobdent row. I think it's better using a new app script for this task