Membership query examples for dynamic groups

You can use all of the conditions in the table to create membership queries for dynamic groups using the Admin console. 

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.

 

Condition

Edit in the Admin Console*

Sample Code

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))

*Conditions you can't edit in the admin console can be edited in Update a user account.

**Start typing the manager's email address into the User Email field, and then select it when it autofills. You'll get an error if you try to create the group by typing the full email address.

Was this helpful?
How can we improve it?

Need more help?

Sign in for additional support options to quickly solve your issue

Search
Clear search
Close search
Google apps
Main menu
Search Help Center
false
false
true
73010
false
false