I'd like to have valuesToCopy be separated by a space where the commas are created by getDisplayValues() in the popup so it doesn't appear as one long string. I'm using getDisplayValues() because there are dates that I don't want to change the formatting for.
function TextBox() {
var ui = SpreadsheetApp.getUi();
const sheet = SpreadsheetApp.openById('1JZ-v5n5m0_lyaoLgsHDAa78AtYNP5AsUDo2NRpJbwG4').getSheetByName('HOT WARM CLIENTS');
sheet.sort(9)
var today = Utilities.formatDate(new Date(), "GMT 1", "MM/dd/yy")
var ui = SpreadsheetApp.getUi();
var valuesToCopy = sheet.getRange("D5:J5").getDisplayValues()
var ar2 = [
{
message: valuesToCopy "\n\n Did we do work for this client today/yesterday?",
range: "G5"
}
];
ar2.forEach(({message, range }) => {
var res = ui.prompt(message, ui.ButtonSet.YES_NO);
if (res.getSelectedButton() == ui.Button.YES) {
sheet.getRange(range).setValue(res.getResponseText());
SpreadsheetApp.getUi();
} else {
Logger.log('The user clicked "No" or the dialog\'s close button.');
}
})
I've tried
valuesToCopy = valuesToCopy.split(',')
and I get an error: TypeError: valuesToCopy.split is not a function
CodePudding user response:
var valuesToCopy = sheet.getRange("D5:J5").getDisplayValues().map(r => r.join(' '));