Creating a spreadsheet that will upon either being opened or refreshed should pop up a prompt asking me for the day, store that value in a particular cell and then proceed to ask me a series of other questions.
This is what I have so far:
function onOpen()
{
// Prompt for the value
const day = SpreadsheetApp.getUi().prompt("Please enter the day.").getResponseText();
//Get all pages in spreadsheet and iterate through
const sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
for(var i = 0; i < sheets.length; i++ )
{
//Set the value in the cell B3 of the page
sheets[i].getRange("B2").setValue( day );
}
if (day.toLowerCase() === 'monday') {
function martialArts() {
const mma = ui.alert("Did you go to MMA training today?".ui.ButtonSet.YES_NO);
if(mma == ui.Button.YES) {
sheets.getRange('C2').setValue(mma)
}
}
}
}
When I run the script I only get a prompt asking for the day, if I enter Monday this is stored by the other prompt (the question "Did you go to MMA training today") does not run. Additionally, this script does not run upon opening or refreshing my sheet