The following code works perfectly if run normally
function initialPopulation()
{
var group = ContactsApp.getContactGroup('clients');
var myContacts = ContactsApp.getContactsByGroup(group);
for (var i=0;i<myContacts.length;i++)
{
var row = i+1;
var getPrimaryEmail = myContacts[i].getPrimaryEmail();
ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
ss.getRange("A"+row).setValue(getPrimaryEmail);
var temp=0;
}
}
If I debug the code, without any stops, it also runs perfectly without issues.
However, if I try to debug the code, with a stop on the line "temp=0", then continue to debug, it will always crash:
We're sorry, a server error occurred. Please wait a bit and try again. (line 10, file "Code")
Line 10 is:
var getPrimaryEmail = myContacts[i].getPrimaryEmail();
Any ideas what could be happening?
This is driving me crazy because I cannot debug more complex code.
I can confirm this, even in an older script that I am fairly certain I have previously single-stepped through. What a show-stopper.
Further, you can reproduce the same error with .contact.getEmails()
, so my bet is that a bug has been introduced. No sign of it on the issue tracker, unless you count Issue 5502.
I recommend raising a new issue. (Done: Issue 5515.)
In the mean time, you can work around the problem by NOT single stepping over methods like this one that the debugger can't unspool. That means that you cannot have any breakpoints BEFORE the fatal line, as it will die on continuation.