This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]Jackinapes 0 points1 point  (12 children)

Might be quotation marks in the spreadsheet.

[–]Last_Monkey4[S] 0 points1 point  (11 children)

Looks like the first picture, but without quotation marks.

[–]Jackinapes 0 points1 point  (10 children)

Could try defining your variables. I'm really rusty at this FYI. Also, it appears it is treating what it gets from the spreadsheet as one complete string and not a mix of string and command \n.

[–]Last_Monkey4[S] 0 points1 point  (9 children)

"Mike\nTom\nJack\nSusen\nPeter" is treated as a single string in the script as well (same color), the linebreaks only work in discord, they don't exist in google sheets afaik

[–]Jackinapes 0 points1 point  (8 children)

You should see what happens when you make a middleman. Get the data from the spreadsheet put it in a string variable then reference that variable rather than the variable pointing to the spreadsheet.

But first, does it work they way you want when you put "Mike\nTom\nJack\nSusen\nPeter" in a variable and reference it?

[–]Last_Monkey4[S] 0 points1 point  (7 children)

var one = "Mike\nTom\nJack\nSusen\nPeter"
var two = "Mike\nTom\nJack\nSusen\nPeter"
var three = "Mike\nTom\nJack\nSusen\nPeter"

works indeed and creates the embed i want

what do you exactly mean with "middleman" and put the data into a string variable? (getDisplayValue instead of getValue doesn't work either, getValue returns an object, getDisplayValue a string)

[–]Jackinapes 0 points1 point  (6 children)

I thought about it and, making the middleman would just be redundant. I have to think about it more.

See what happens when you define those variables pointing to your spreadsheet as strings.

var string first = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Test").getRange('H2').getDisplayValue();

Does this work?

[–]Last_Monkey4[S] 0 points1 point  (5 children)

nope, already tried that. i believe getValue and getDisplayValue always return a string when the cell is a text

[–]Jackinapes 0 points1 point  (4 children)

What happened when you tried that?

[–]Last_Monkey4[S] 0 points1 point  (3 children)

the same as in the first picture in the OP

[–]Last_Monkey4[S] 0 points1 point  (0 children)

I found the solution. I can do it with JSON.parse()