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

291
Views
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 answers
Answer question

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 Report
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!