CNContactStore.Groups
---------------------

Queries list of all groups.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Contacts](component_Contacts.md) | [8.4](newinversion84.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ✅ Yes |

MBS( "CNContactStore.Groups" ) ### Parameters

none

### Result

Returns list or error.

### Description

Queries list of all groups.  
You get back a list with the group identifiers.  
### Examples

Show groups with IDs and names in field:

 Set Variable \[ $groups ; Value: MBS ( "CNContactStore.Groups" ) \]   
Set Variable \[ $count ; Value: ValueCount ( $groups ) \]   
If \[ $count &gt; 0 \]   
 Set Variable \[ $index ; Value: 1 \]   
 Set Variable \[ $text ; Value: "" \]   
 Loop  
 #   
 Set Variable \[ $groupID ; Value: GetValue($groups ; $index ) \]   
 Set Variable \[ $groupName ; Value: MBS ( "[CNGroup.Name](CNGroupName.md)"; $groupID ) \]   
 Set Variable \[ $text ; Value: $text &amp; $GroupName &amp; " " &amp; $groupID \]   
 #   
 # next  
 Set Variable \[ $index ; Value: $index + 1 \]   
 Exit Loop If \[ $index &gt; $count \]   
 Set Variable \[ $text ; Value: $text &amp; ¶ \]   
 End Loop  
End If  
Set Field \[ Contacts::Result ; $text \]  
Queries group names:

 While(   
\[   
 names = "";   
 // query list of group IDs  
 list = MBS ( "CNContactStore.Groups" );   
 count = ValueCount(list);   
 index = 1  
\] ;   
 index ≤ count ;   
\[   
 id = GetValue(list; index);   
 // query name for each ID  
 name = MBS ( "[CNGroup.Name](CNGroupName.md)"; id);   
 names = names &amp; id &amp; " -&gt; " &amp; name &amp; ¶;   
 index = index + 1   
\] ;   
// return all the names  
names )  
### See also

- [CNContactStore.AddGroup](CNContactStoreAddGroup.md)
- [CNContactStore.Country](CNContactStoreCountry.md)
- [CNContactStore.GroupsByName](CNContactStoreGroupsByName.md)
- [CNContactStore.GroupsForContact](CNContactStoreGroupsForContact.md)
- [CNContactStore.RequestAccesss](CNContactStoreRequestAccesss.md)
- [CNContactStore.Subgroups](CNContactStoreSubgroups.md)
- [CNGroup.Name](CNGroupName.md)

### Example Databases

- [Mac and iOS/Contacts/Contacts Dialogs](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Contacts/Contacts%20Dialogs.shtml#2ScriptAnchor_)
- [Mac and iOS/Contacts/Contacts to FileMaker](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Contacts/Contacts%20to%20FileMaker.shtml#3ScriptAnchor_)
- [Mac and iOS/Contacts/Contacts](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Contacts/Contacts.shtml#4ScriptAnchor_)
- [Mac and iOS/Contacts/ContactsChanged](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Contacts/ContactsChanged.shtml#4ScriptAnchor_)

This function checks for a license.

Created 1st August 2018 , last changed 14th June 2022

  
[CNContactStore.GroupHierarchy](CNContactStoreGroupHierarchy.md) - [CNContactStore.GroupsByName](CNContactStoreGroupsByName.md)

[HTML Version](CNContactStoreGroups.shtml)