Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can you split the the values from getDisplayValues() so that it appears with spaces instead of commas in the textbox popup?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

var valuesToCopy = sheet.getRange("D5:J5").getDisplayValues().map(r => r.join(' '));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading