There’s clearly some obvious error(s) on my part, but I just can’t seem to figure out what I’ve done wrong.
The variable called check in the code below is not being recognised in the If statement, and the If statement code following the if statement is being run regardless of the outcome of the if statement – any ideas what I’m doing wrong?
I’m trying to check for particular text in one table and if its not found then run a prompt for the user to enter some text which is added to the destinationTable.
<code>function check(){
var destinationTbl = SlidesApp.getActivePresentation().getPageElementById('g2daca31a7a8_0_9').asTable();
var textToCheck = SlidesApp.getActivePresentation().getPageElementById('g2daca31a7a8_0_0').asTable().getCell(0,1).getText().valueOf();
if (textToCheck != 'check this'){
let entry = SlidesApp.getUi().prompt(`${'Please enter your license details'}`);
let response= entry.getResponseText();
if (response!=""){
destinationTbl.getCell(0,1).getText().setText(response)}
}}
</code>
<code>function check(){
var destinationTbl = SlidesApp.getActivePresentation().getPageElementById('g2daca31a7a8_0_9').asTable();
var textToCheck = SlidesApp.getActivePresentation().getPageElementById('g2daca31a7a8_0_0').asTable().getCell(0,1).getText().valueOf();
if (textToCheck != 'check this'){
let entry = SlidesApp.getUi().prompt(`${'Please enter your license details'}`);
let response= entry.getResponseText();
if (response!=""){
destinationTbl.getCell(0,1).getText().setText(response)}
}}
</code>
function check(){
var destinationTbl = SlidesApp.getActivePresentation().getPageElementById('g2daca31a7a8_0_9').asTable();
var textToCheck = SlidesApp.getActivePresentation().getPageElementById('g2daca31a7a8_0_0').asTable().getCell(0,1).getText().valueOf();
if (textToCheck != 'check this'){
let entry = SlidesApp.getUi().prompt(`${'Please enter your license details'}`);
let response= entry.getResponseText();
if (response!=""){
destinationTbl.getCell(0,1).getText().setText(response)}
}}
Heres a link to the file