Home > Software design >  Can you put code in alerts for app script
Can you put code in alerts for app script

Time:03-31

I'm new to app script and I was just wondering if there was a way to input a cell value into an alert.

I tried

var ui=SpreadsheetApp.getUi()
var winScreeen = ui.alert('Win:',sr.getRange('U5').getValue())

CodePudding user response:

Instead of

var winScreeen = ui.alert('Win:',sr.getRange('U5').getValue())

use

var winScreeen = ui.alert('Win:'   sr.getRange('U5').getValue())

The above used to concatenate two values.

CodePudding user response:

Another way to alert

function myalert() {
  const ss = SpreadsheetApp.getActive();
  SpreadsheetApp.getUi().alert(`win:${ss.getRange("Sheet0!A2").getValue()}`);
}

Template Literals

  • Related