1

I need to split a value from a cell into separate array values. I am taking a list of emails from my spreadsheet and need to use the addCommenters() method.

Spreadsheets cell value: [email protected], [email protected], [email protected] ... etc.

I need to split around the ", " properly to pass the array into addCommenters().

What is the programmatic way to do this?

1
  • The "duplicate" covers more than just splitting the string, I know. Commented Oct 26, 2015 at 18:37

1 Answer 1

4

If you get the value of that cell (using .getValue())

var emails = sheet.getRange(range_here).getValue()

and then apply the split() method

var commentersArray = emails.split(",")

you will have an array you can pass to the .addCommenters() method.

file.addCommenters(commentersArray);
Sign up to request clarification or add additional context in comments.

3 Comments

I wasn't sure if this would work because it doesn't show the drop-down menu for this method. Why does it not autocomplete like other methods?
Not sure. Maybe because it is not a 'pure' GAS method but rather a javaScript method ?
That makes sense, it would be impractical to add all javascript in there. Can you please assist on my other question related to this same project?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.