AI-generated Key Takeaways
-
Fetches negative keyword lists based on specified criteria, such as name, ID, or shared set attributes.
-
Allows for filtering results using conditions like
CONTAINS
,>
,=
, and more, with support for combining multiple conditions. -
Enables sorting the results by different columns in ascending or descending order, for example, by shared set name or ID.
-
Provides methods for limiting the number of returned entities and for selecting specific negative keyword lists by their IDs or resource names.
-
Returns an iterator (
AdsApp.NegativeKeywordListIterator
) to access the fetched negative keyword lists.
Typical usage:
var negativeKeywordListSelector = AdsApp.negativeKeywordLists() .withCondition("Name CONTAINS 'test'") .withLimit(1) .withIds([10,20]) .orderBy("SharedSetId DESC"); var negativeKeywordListIterator = negativeKeywordListSelector.get(); while (negativeKeywordListIterator.hasNext()) { var negativeKeywordList = negativeKeywordListIterator.next(); }
Methods:
Member | Type | Description |
---|---|---|
get() | AdsApp.NegativeKeywordListIterator |
Fetches the requested negative keyword lists and returns an iterator. |
orderBy(orderBy) | AdsApp.NegativeKeywordListSelector |
Specifies the ordering of the resulting entities. |
withCondition(condition) | AdsApp.NegativeKeywordListSelector |
Adds the specified condition to the selector in order to narrow down the results. |
withIds(ids) | AdsApp.NegativeKeywordListSelector |
Restricts this selector to return only negative keyword lists with the given negative keyword list IDs. |
withLimit(limit) | AdsApp.NegativeKeywordListSelector |
Specifies limit for the selector to use. |
withResourceNames(resourceNames) | AdsApp.NegativeKeywordListSelector |
Restricts this selector to return only negative keyword lists with the given Google Ads API resource names. |
get()
Fetches the requested negative keyword lists and returns an iterator. Return values:
Type | Description |
---|---|
AdsApp.NegativeKeywordListIterator |
Iterator of the requested negative keyword lists. |
orderBy(orderBy)
Specifies the ordering of the resulting entities. orderBy
parameter can have one of the following forms:
orderBy("shared_set.name")
- orders results by shared_set.name, in ascending order.orderBy("shared_set.name ASC")
- orders results by shared_set.name, in ascending order.orderBy("shared_set.name DESC")
- orders results by shared_set.name, in descending order.
See NegativeKeywordListSelector.withCondition(String) for enumeration of columns that can be used.
orderBy()
may be called multiple times. Consider the
following example:
negativeKeywordListSelector = negativeKeywordListSelector .orderBy("shared_set.name ASC") .orderBy("shared_set.id DESC");
The results will be ordered by shared_set.name in ascending order. Results with equal shared_set.name value will be ordered by shared_set.id in descending order.
Arguments:
Name | Type | Description |
---|---|---|
orderBy | String |
Ordering to apply. |
Return values:
Type | Description |
---|---|
AdsApp.NegativeKeywordListSelector |
The selector with ordering applied. Adds the specified condition to the selector in order to narrow down the results. |
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:
negativeKeywordListSelector = negativeKeywordListSelector .withCondition("SharedSetId > 5") .withCondition("Name CONTAINS 'negative keyword list'");
AND
-ed together. The above
example will retrieve
negative keyword lists that have a Shared Set Id greater than 5 and
contains
"negative keyword list" in its name.
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
Integer
andLong
columns (e.g. SharedSetId):< <= > >= = !=
- For
String
columns (e.g. Name):= != (NOT) (LIKE | CONTAINS | REGEXP_MATCH)
- For
Enumeration
columns (ones that can only take one value from a predefined list, such as Status):= != IN () NOT IN ()
IN
, NOT IN
, CONTAINS
ALL
, CONTAINS ANY
and CONTAINS NONE
operators look as follows:
withCondition("Name IN (Value1, Value2)")
Columns
All column names are case-sensitive, and so are all values of enumerated columns (such as Status).
Column | Type | Example |
---|---|---|
|
||
shared_set.name | String | withCondition("shared_set.name = 'my shared set'") |
shared_set.id | Long | withCondition("shared_set.id > 5") |
shared_set.status | Enumeration: ENABLED , REMOVED |
withCondition("shared_set.status = ENABLED") |
Arguments:
Name | Type | Description |
---|---|---|
condition | String |
Condition to add to the selector. |
Return values:
Type | Description |
---|---|
AdsApp.NegativeKeywordListSelector |
The selector with the condition applied. |
withIds(ids)
Restricts this selector to return only negative keyword lists with the
given
negative keyword list IDs.
var negativeKeywordListIds = ['12345', '23456', '34567']; selector = selector.withIds(negativeKeywordListIds);
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:
AdsApp.negativeKeywordLists() .withIds(['12345', '23456', '34567']) .withIds(['34567', '45678', '56789']);
34567
, since it
would be the only
negative keyword list 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 | Object[] |
Array of negative keyword list IDs. |
Return values:
Type | Description |
---|---|
AdsApp.NegativeKeywordListSelector |
The selector restricted to the given IDs. |
withLimit(limit)
Specifies limit for the selector to use. For instance,
withLimit(50)
returns only the first 50 entities. Arguments:
Name | Type | Description |
---|---|---|
limit | int |
How many entities to return. |
Return values:
Type | Description |
---|---|
AdsApp.NegativeKeywordListSelector |
The selector with limit applied. |
withResourceNames(resourceNames)
Restricts this selector to return only negative keyword lists with the
given Google Ads API resource names.
const negativeKeywordListResourceNames = [ 'customers/1234567890/sharedSets/111', 'customers/1234567890/sharedSets/222', 'customers/1234567890/sharedSets/333', ]; selector = selector.withResourceNames(negativeKeywordListResourceNames);
The resulting selector can be further refined by applying additional conditions to it. The resource name condition will then be AND-ed together with all the other conditions.
The selector can only support up to 10,000 resource names. If more than 10,000 resource names are specified, the corresponding get() call will fail with a runtime error.
Arguments:
Name | Type | Description |
---|---|---|
resourceNames | String[] |
Array of negative keyword list resource names. |
Return values:
Type | Description |
---|---|
AdsApp.NegativeKeywordListSelector |
The selector restricted to the given resource names. |