To create membership queries for dynamic groups in the Google Admin console, you specify conditions using default standard attributes or custom attributes that you create, or both. By default, users who match the conditions are added to the group. Optionally, for each condition, you can instead choose to exclude users who match the condition from group membership.
You can edit user accounts so that a user is included in a dynamic group. You can make some changes using fields in the Admin console. For the others, use Update a user account.
Use standard attributes
You can use all of the attributes in this table to create membership queries for dynamic groups. When you create a dynamic group in the Admin console, you select standard attributes from the Conditions list.
Attribute |
Can edit in the Admin console |
Must use the API to edit |
Sample code |
Country addresses.country |
|
user.addresses.exists(address, address.country == 'Canada') |
|
addresses.country_code |
|
user.addresses.exists(address, address.country_code == '555') |
|
addresses.custom_type |
|
user.addresses.exists(address, address.custom_type=='Custom address type') |
|
addresses.extended_address |
|
user.addresses.exists(address, address.extended_address=='California, USA') |
|
addresses.locality |
|
user.addresses.exists(address, address.locality=='Southern California') |
|
addresses.po_box |
|
user.addresses.exists(address, address.po_box=='87132') |
|
addresses.primary |
|
user.addresses.exists(address, address.primary==true) |
|
addresses.postal_code |
|
user.addresses.exists(address, address.postal_code=='94040') |
|
addresses.region |
|
user.addresses.exists(address, address.region=='Southwest') |
|
addresses.street_address |
|
user.addresses.exists(address, address.street_address=='123 Fake St') |
|
addresses.type |
✔ |
user.addresses.exists(address, address.type==2) |
|
emails.address |
✔ |
user.emails.exists(email, email.address.startsWith('employee')) |
|
emails.custom_type |
|
email.address.startsWith('custom@google.com') |
|
emails.primary |
✔ |
user.emails.exists(email, email.primary==true) |
|
emails.type |
✔ |
user.emails.exists(email, email.type==2) |
|
external_ids.custom_type |
|
user.external_ids.exists(id, id.custom_type.startsWith('runner')) |
|
external_ids.type |
|
user.external_ids.exists(id, id.type==3) |
|
external_ids.value |
✔ |
user.external_ids.exists(id, id.value=='contractor') |
|
gender.address_me_as |
|
user.gender.address_me_as=='they/them' |
|
gender.custom_gender |
|
user.gender.custom_gender.startsWith('custom gender') |
|
gender.type |
|
user.gender.type==3 |
|
ims.custom_protocol |
|
user.ims.exists(im, im.custom_protocol.startsWith('custom')) |
|
ims.custom_type |
|
user.ims.exists(im, im.custom_type.startsWith('custom')) |
|
ims.standard_protocol |
|
user.ims.exists(im, im.standard_protocol==7) |
|
ims.primary |
|
user.ims.exists(im, im.primary==true) |
|
ims.type |
|
user.ims.exists(im, im.type==3) |
|
ims.value |
|
user.ims.exists(im, im.value=='chat') |
|
keywords.custom_type |
|
user.keywords.exists(keyword, keyword.custom_type.startsWith('contractor')) |
|
keywords.type |
|
user.keywords.exists(keyword, keyword.type==3) |
|
keywords.value |
|
user.keywords.exists(keyword, keyword.value=='engineer') |
|
languages.language_code |
|
user.languages.exists(language, language.language_code=='English') |
|
locations.area |
|
user.locations.exists(loc, loc.area=='Near San Francisco') |
|
locations.building_id |
✔ |
user.locations.exists(loc, loc.building_id=='Building 25') |
|
locations.custom_type |
|
user.locations.exists(loc, loc.custom_type=='Region') |
|
locations.desk_code |
|
user.locations.exists(loc, loc.desk_code=='Desk 37') |
|
locations.floor_name |
✔ |
user.locations.exists(loc, loc.floor_name=='3rd floor') |
|
locations.floor_section |
✔ |
user.locations.exists(loc, loc.floor_section=='East Section') |
|
locations.type |
|
user.locations.exists(loc, loc.type==1) |
|
name.family_name |
✔ |
user.name.family_name=='Washington' |
|
name.given_name |
✔ |
user.name.given_name=='George' |
|
name.value |
✔ |
user.name.value=='George Washington' |
|
organizations.cost_center |
✔ |
user.organizations.exists(org, org.cost_center=='Department X') |
|
organizations.custom_type |
|
user.organizations.exists(org, org.custom_type=='nonprofit') |
|
organizations.department |
✔ |
user.organizations.exists(org, org.department=='Sales') |
|
organizations.description |
✔ |
user.organizations.exists(org, org.description=='search provider') |
|
organizations.domain |
|
user.organizations.exists(org, org.domain=='example.net') |
|
organizations.location |
|
user.organizations.exists(org, org.location=='California') |
|
organizations.name |
|
user.organizations.exists(org, org.name=='Google') |
|
organizations.primary |
|
user.organizations.exists(org, org.primary==true) |
|
organizations.symbol |
|
user.organizations.exists(org, org.symbol=='GOOG') |
|
organizations.title |
✔ |
user.organizations.exists(org, org.title=='Manager') |
|
organizations.type |
|
user.organizations.exists(org, org.type==2) |
|
phones.custom_type |
|
user.phones.exists(phone, phone.custom_type.startsWith('new type')) |
|
phones.primary |
|
user.phones.exists(phone, phone.primary==true) |
|
phones.type |
✔ |
user.phones.exists(phone, phone.type==3) |
|
phones.value |
✔ |
user.phones.exists(phone, phone.value=='555-5555') |
|
relations.custom_type |
|
user.relations.exists(rel, rel.custom_type=='example') |
|
relations.type |
|
user.relations.exists(rel, rel.type==12) |
|
relations.value |
|
user.relations.exists(rel, rel.value=='Sundar') |
|
websites.custom_type |
|
user.websites.exists(site, site.custom_type.startsWith('creative writing')) |
|
websites.primary |
|
user.websites.exists(site, site.primary==true) |
|
websites.type |
|
user.websites.exists(site, site.type==2) |
|
websites.value |
|
user.websites.exists(site, site.value=='google.com') |
|
archived |
✔ |
user.archived==true |
|
change_password_at_next_login |
✔ |
user.change_password_at_next_login==true |
|
is_2sv_enforced |
✔ |
user.is_2sv_enforced==true |
|
is_enrolled_in_2sv |
✔ |
user.is_enrolled_in_2sv==true |
|
is_mailbox_setup |
✔ |
user.is_mailbox_setup==true |
|
suspended |
✔ |
user.suspended==true |
|
suspension_reason |
|
user.suspension_reason==2 |
|
org_units.org_unit_id |
✔ |
user.org_units.exists(org_unit, org_unit.org_unit_id==orgUnitId('03ph8a2z1kqs27e')) |
|
org_unit_id |
✔ |
user.org_unit_id==orgUnitId('03ph8a2z1kqs27e') |
|
managers.user_id** |
✔ |
user.managers.exists(manager, manager.user_id==user_id('2d8374y)) |
* If you can’t change a user’s account detail in the Admin console, you can edit it in the Google Cloud API. For details, go to Update a user account.
** Start entering the manager's email address in the User Email field. Then, select the address when it autofills. You'll get an error if you try to create the group by entering the full email address.
Use custom attributes
You can create custom attributes using the Google Cloud API. When you create a membership query in the Admin console, custom attributes appear after the standard attributes in the Condition list.
If you run a query that contains a custom attribute and the query returns zero members, the attribute properties might be incorrectly set in the API. Specifically, the indexed
property needs to be set to true.
Exclude users from group membership
You can create a condition for a dynamic group and then choose to allow only users who do not meet the condition to be added as group members. In other words, you can exclude users who meet the condition from group membership.
To allow only users who do not meet a condition to be added to the group, create the condition and then click Exclude . For example, to create a group containing only users who don’t live in the U.S., you create the condition “Country code equals US” and then click Exclude
. The exclusion is represented in the query by an exclamation point (!).
For some queries that you create, the query contains the “exists” parameter. For example, if your query includes the Country condition, the query text contains “user.addresses.exists.” In some cases, you can’t use the exclude option in a query that includes the “exists” parameter. For details, go to Formulating and testing your query.