Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
Issue using setValues to append and fill a column in sheets with an array passed via a function

Here's the scenario: On clicking a button, 11 pieces of user data are taken from a web form and inserted into the userInfo array in function doStuff. I then attempt to pass userInfo to userClicked to append a column into a googlesheet with the new user data. My lack of understanding on how to construct, pass and present array data is my issue here I think and a couple of online tutorials have not really helped me. Thanks for advice/answers.

function doStuff(){
    
    var userInfo ={};
    
    userInfo.username = document.getElementById("username").value;
    userInfo.teamname = document.getElementById("teamname").value;
    userInfo.email = document.getElementById("email").value;
    userInfo.m_p1 = document.getElementById("m_p1").value;
    userInfo.m_p2 = document.getElementById("m_p2").value;
    userInfo.m_p3 = document.getElementById("m_p3").value;
    userInfo.m_p4 = document.getElementById("m_p4").value;
    userInfo.m_p5 = document.getElementById("m_p5").value;
    userInfo.m_p6 = document.getElementById("m_p6").value;
    userInfo.m_p7 = document.getElementById("m_p7").value;
    userInfo.m_p8 = document.getElementById("m_p8").value;
    

    google.script.run.userClicked(userInfo);
{

function userClicked(userInfo){
  var ss = SpreadsheetApp.openByUrl(url);
  var ws = ss.getSheetByName("UserData");

  ws.insertColumnAfter(ws.getMaxColumns());
  ws.getRange(1,ws.getLastColumn()+1,12,1).setValues(userInfo);
}

The userInfo array looks as follows from the log: [{m_p2=Choose Player 2, m_p6=Choose Player 6, m_p8=Choose Player 8, m_p1=6 R Nadal, m_p3=Choose Player 3, email=, username=, m_p5=Choose Player 5, m_p4=Choose Player 4, m_p7=Choose Player 7, teamname=}]

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!