function fetchFileParameters(mType) {
var ss=SpreadsheetApp.getActive();
var sh=ss.getActiveSheet();
html+='<body><br />';
html+='<input type="hidden" id="hd" value="'+mType+'">';
html+='<label for="yr">Enter YEAR</label><br />';
html+='<input type="text" id="yr" /><br /><br />';
html+='<label for="tm">Enter TERM (eg. Term 2)</label><br />';
html+='<input type="text" id="tm" /><br />';
html+=Utilities.formatString('<br /><input type="radio" name="rgroup" id="%s" value="%s" onChange="getSelected();" />%s','id'+ Number(1),'radio' + Number(1),' Copy <br />');
html+=Utilities.formatString('<br /><input type="radio" name="rgroup" id="%s" value="%s" onChange="getSelected();" />%s','id'+ Number(2),'radio' + Number(2),' Move <br />');
html+='<script>';
html+='function getSelected(){';
html+='var selected=document.querySelector(\'input[name="rgroup"]:checked\').value;';
html+='var pYear=document.getElementById("yr").value;';
html+='var pTerm=document.getElementById("tm").value;';
html+='var pType=document.getElementById("hd").value;';
html+='google.script.run.withSuccessHandler(function(){google.script.host.close();}).displayChoice(selected,pYear,pTerm,pType);}</script></body></html>';
var ui=HtmlService.createHtmlOutput(html).setHeight(220).setWidth(250);
SpreadsheetApp.getUi().showModalDialog(ui, 'Copy/Move Files');
}
var copyMove;
var yr;
var tm;
var mType;
function displayChoice(selected,pYear,pTerm,pType){
copyMove = selected;
yr = pYear;
tm = pTerm;
mType = pType;
goFurther(mType);
//if(pType=="Splits") copyFilesByPupilName();
//if(pType=="Clones") copyFilesToAllPupils();
SpreadsheetApp.getUi().alert(mType);
}
The above code works perfectly, but if I uncomment either
if(pType=="Splits") copyFilesByPupilName(); OR
if(pType=="Clones") copyFilesToAllPupils();
the dialog remains open and then nothing happens. I can run either function by calling it directly, so there are no errors in them, so why can I not call them from within the displayChoice function.
I notice also that if I put a breakpoint in the displayChoice function it is ignored.
Any ideas?