Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7858589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:31:11+00:00 2026-06-02T21:31:11+00:00

I want to add ABRecordRef to existing Group. Some how its not working. Here

  • 0

I want to add ABRecordRef to existing Group. Some how its not working. Here is my code:

-(void)addUsers:(NSMutableArray*)users toGroupID:(ABRecordID)groupID {

    CFErrorRef error = NULL;
    ABAddressBookRef addressBookRef = ABAddressBookCreate();

   // Get Group 
    ABRecordRef group = ABAddressBookGetGroupWithRecordID(addressBookRef,groupID);

    for (User *user in users) {

        int recordId = user.uniqID;

        ABRecordRef person = ABAddressBookGetPersonWithRecordID(addressBookRef,(ABRecordID)recordId);

        //add the new person to the record
        ABAddressBookAddRecord(addressBookRef, person, nil); 
        ABAddressBookSave(addressBookRef, &error);

        // add the group   
        ABAddressBookAddRecord(addressBookRef, group, &error); 
        ABAddressBookSave(addressBookRef, &error);

        // add the person to the group 
        ABGroupAddMember(group, person, &error);         
        ABAddressBookSave(addressBookRef, &error);

        //save the record
        ABAddressBookSave(addressBookRef, nil);

        if (!isMemberAdded) {
            [self showAlertWithTitle:@"Alert" andMessage:@"Some Error Occured While Adding User to Existing Group"];
        }
    }
    BOOL isMembersAddedToGroup = ABAddressBookSave(addressBookRef, nil); 
    if (isMembersAddedToGroup) {
        [self showAlertWithTitle:@"Alert" andMessage:@"Selected Members Added to Existing Group Successfully"];
    }
    else{
        [self showAlertWithTitle:@"Alert" andMessage:@"Some Error Occured While Adding User to Existing Group"];
    }
    CFRelease(addressBookRef);
}

Whenever I use above code & try to save it in existing group I get following message in console

CPSqliteStatementPerform: constraint failed for INSERT INTO ABGroupMembers (group_id, member_type, member_id) VALUES (?, ?, ?);
CPSqliteStatementReset: columns group_id, member_type, member_id are not unique for INSERT INTO ABGroupMembers (group_id, member_type, member_id) VALUES (?, ?, ?);

I am not getting what I am missing in above code.
Any knid of help is appreciated. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T21:31:12+00:00Added an answer on June 2, 2026 at 9:31 pm

    If we see the message:

    CPSqliteStatementPerform: constraint failed for INSERT INTO ABGroupMembers (group_id, member_type, member_id) VALUES (?, ?, ?);
    CPSqliteStatementReset: columns group_id, member_type, member_id are not unique for INSERT INTO ABGroupMembers (group_id, member_type, member_id) VALUES (?, ?, ?);
    

    Also in documentation :

    The ABAddressBook opaque type (whose instances are known as address
    books) provides a programming interface to the Address Book—a
    centralized database used by multiple applications to store personal
    information about people

    (So, internally, this error is caused due to incorrect sqlite query.)

    It indicates that there is some issue with ABGroupAddMember or ABAddressBookAddRecord(addressBookRef, group, &error); call.

    The problem can be: We have group and person references already with us when we callABAddressBookGetGroupWithRecordID and ABAddressBookGetGroupWithRecordID functions.

    Now, when ABAddressBookAddRecord is executed for both( person and group) it is adding them to addressbook but not updating their UniqueIds(id for person and group ref.) so at the time of ABGroupAddMember function call it has person and group with same ids which are added in ABGroupMembers table.

    Please, try to print recordId for person and group after you add them to address book(and before you add them to group). if recordsIds are not updated then that is the cause, and you will need to fetch record for new recordId. Also check whether the new person and group are being added to addresbook or not.

    *Currently, I do not mac access to verify my suggestion/answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want add days to an NSDate . The approach below is not working.
I am using the following code but still its not able to add contact
I want add some resource files (non-code text-based files) to the jar file in
I have a website built with ASP.NET (3.5) and want add some level of
I want to add some jQuery functionality to our sites where one piece of
I want to add some html in an email. I've tried the following. vFromName
I want add a UIToolbar to the keyboard for my UITextField . Here is
I want add my page some div and another tags.I wanna give unique class
I have a table with some rows and inputs inside them. I want add
I want add user in ActiveDirectory. I use this code private SPUser CreateUser(string strLoginName,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.