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.
The script does not respond.?For the if statement for example - using: if(userInfo.userDetail = 1) {perform action} then it will perform action irrespective of whether userDetail is 1 or no, if you doesn't miscopy your script, I think thatif(userInfo.userDetail = 1)is required to beif(userInfo.userDetail == 1). How about this?