Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

293
Visualizações
How do I access a variable passed in an object array from client side to server side in js/googlescript

New js-er here so appreciate the support. I am passing an object array, userInfo{}, which has the following contents :

{"userName":"bob","userID":12345,"userDetail":1} from a client-side JavaScript using google.script.run.userClicked(userInfo).

Have used JSON.stringify() in an alert box to make sure the object array being passed is in the above format and then on the server side I am able to use the data when writing to a googlesheet cell.

e.g. ss.getRange(2, userInfo.userID).setValue(userInfo.userName).

This works fine.

My issue is when I want to use userInfo data in the server side script as a parameter:

e.g. var newUserDetail = userInfo.userDetail + 5; or if (userInfo.userDetail = 1) {perform action} etc.

The script does not respond. Do I need to transform the object array elements somehow ? Or use a different syntax to userInfo.userDetail ?

Have searched for on variants of how to access variables passed from client side to server side in js/gs' with no success. I am sure this is super-obvious but still learning - so all help appreciated.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

The issue might be the way you are writing the condition inside of your if statement. In javascript, to compare two values you should use either == or ===.

== is used to compare two values regardless of their types, for example console.log("22" == 22) will print true. While console.log("22" === 22) will print false.

You mention your if statement having the condition userInfo.userDetail = 1, while it should be userInfo.userDetail === 1

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda