AdsApp.​SearchCampaignAudienceIterator

  • audienceIterator allows you to iterate through a collection of SearchCampaignAudience objects.

  • It provides methods like hasNext(), next(), and totalNumEntities() to navigate and access audience data.

  • hasNext() checks for more elements, next() retrieves the next audience, and totalNumEntities() gives the total count matched by the selector.

  • This iterator helps efficiently process and manage audiences within Google Ads scripts by accessing individual SearchCampaignAudience instances.

An iterator of audiences.

Typical usage:

while (audienceIterator.hasNext()) {
  var audience = audienceIterator.next();
}
Related:

Methods:

MemberTypeDescription
hasNext() boolean Returns true if the iterator has more elements.
next() AdsApp.SearchCampaignAudience Returns the next SearchCampaignAudience in the iterator.
totalNumEntities() int Returns the total number of entities matched by the selector which generated this iterator.

hasNext()

Returns true if the iterator has more elements.

Return values:

TypeDescription
boolean true if the iterator has more elements.

next()

Returns the next SearchCampaignAudience in the iterator.

Return values:

TypeDescription
AdsApp.SearchCampaignAudience The next SearchCampaignAudience in the iterator.

totalNumEntities()

Returns the total number of entities matched by the selector which generated this iterator.

Note that the returned number disregards limits, and that the iterator is not guaranteed to have this many elements — hasNext will start to return false and next will start to throw exceptions as soon as the limit for entity reads has been reached, even if the selector matched more entities.

Return values:

TypeDescription
int The number of entities matched by the selector which generated this iterator.