Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

CNContactStore.Groups

Queries list of all groups.

Component Version macOS Windows Linux Server iOS SDK
Contacts 8.4 ✅ 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 > 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"; $groupID ) ]
        Set Variable [ $text ; Value: $text & $GroupName & " " & $groupID ]
        #
        # next
        Set Variable [ $index ; Value: $index + 1 ]
        Exit Loop If [ $index > $count ]
        Set Variable [ $text ; Value: $text & ¶ ]
    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"; id);
    names = names & id & " -> " & name & ¶;
    index = index + 1
] ;
// return all the names
names )

See also

Example Databases

This function checks for a license.

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


CNContactStore.GroupHierarchy - CNContactStore.GroupsByName