heystack

Password Protect Script

Demo

From the heystacks.com archiveUpdated 197 views
Open original
View as text

function myFunction() {

ss = SpreadsheetApp.getActiveSpreadsheet();

let pwd ='';

let ui = SpreadsheetApp.getUi();

let bt = ui.Button.CANCEL;

let result = ui.prompt('Enter Password', ui.ButtonSet.OK);

let button = result.getSelectedButton();

topic = result.getResponseText();

if(button == ui.Button.OK && topic == 'UnboxGenie'){

ui.alert('Password entered successfully');

}

else{

while(pwd != 'UnboxGenie' || bt != ui.Button.OK){

let pmt = ui.prompt('Providing password is mandatory', ui.ButtonSet.OK);

pwd = pmt.getResponseText();

bt = pmt.getSelectedButton();

}

ui.alert('Password entered successfully');

}

}

Discussion 0

0/5,000

No discussion yet. Start it — no sign-up needed.