Google Ads Scripts Forum Advisor
unread,Feb 24, 2020, 2:09:35 AM2/24/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to adwords-scripts+apn2wqdwngphxzdr...@googlegroups.com, adwords-scripts+apn2wqdwngphxzdr...@googlegroups.co, adwords...@googlegroups.com
Hi Alberto,
I work with Matt and Ejay and allow me to assist you. Regarding your concern, you can declare a new iterator as you may see in the below sample code :
function main(){
var campaignIterator = AdsApp.campaigns().get();
while (campaignIterator.hasNext()){
var campaign = campaignIterator.next();
Logger.log(campaign.getName());
}
// What must I do to restart the iterator here?
Logger.log("restart iterator");
var campaignIterator = AdsApp.campaigns().get();
while (campaignIterator.hasNext()){
var campaign = campaignIterator.next();
Logger.log(campaign.getName());
}
}
Doing so should "restart" the iterator. But what it actually does is it creates a new instance of the iterator and starts again from the 0 index. Let me know if this is what you're looking for.
Thanks,
Peter