Fetches account labels. Supports filtering.
Typical usage:
var accountLabelSelector = AdsManagerApp.accountLabels()
.withCondition("Name CONTAINS 'priority'");
var accountLabelIterator = accountLabelSelector.get();
while (accountLabelIterator.hasNext()) {
var accountLabel = accountLabelIterator.next();
}
Related:
Methods:
get()
Fetches the requested account labels and returns an iterator.
Return values:
withCondition(condition)
Adds the specified condition to the selector in order to narrow down the results.
Multiple conditions may be added to the same selector:
selector = selector
.withCondition("Name CONTAINS 'PRIORITY'")
.withCondition("Name DOES_NOT_CONTAIN 'FINISHED'");
All specified conditions are
AND
-ed together. The above example will retrieve labels
whose name contains PRIORITY but doesn't contain FINISHED.
The parameter to be passed into this method must be of the following form:
"COLUMN_NAME OPERATOR VALUE"
Operators
The operator that can be used in a condition depends on the type of column.
- For
String
columns (e.g. Name):
= != STARTS_WITH STARTS_WITH_IGNORE_CASE
CONTAINS CONTAINS_IGNORE_CASE DOES_NOT_CONTAIN DOES_NOT_CONTAIN_IGNORE_CASE
Operators are case-sensitive:
starts_with
won't work.
Columns
All column names are case-sensitive.
Column |
Type |
Example |
Name |
String |
withCondition("Name CONTAINS 'priority'") |
Arguments:
Name | Type | Description |
condition |
String |
Condition to add to the selector. |
Return values:
withIds(ids)
Restricts this selector to return only account labels with the given
account label IDs.
var accountLabelIds = [12345, 23456, 34567];
selector = selector.withIds(accountLabelIds);
The resulting selector can be further refined by applying additional conditions to it. The
ID-based condition will then be AND-ed together with all the other conditions, including any
other ID-based conditions. So, for instance, the following selector:
AdsManagerApp.accountLabels()
.withIds([12345, 23456, 34567])
.withIds([34567, 45678, 56789]);
will only get the account label with ID
34567
, since it would be the only
account label that satisfies both ID conditions.
The selector can only support up to 10,000 IDs. If more than 10,000 IDs are specified, the
corresponding get() call will fail with a runtime error.
Arguments:
Name | Type | Description |
ids |
long[] |
Array of account label IDs. |
Return values: