Let the platform do the work

How to Check for Duplicate Records

Overview

An example in bash script demonstrating how to check for duplicate records using the v11 /<module>/duplicateCheck REST POST endpoint.

Duplicate Records

Authenticating

First, you will need to authenticate to the Sugar API. An example is shown below:

  curl -X POST -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{ 
 "grant_type":"password",
 "client_id":"sugar",
 "client_secret":"",
 "username":"admin",
 "password":"password",
 "platform":"custom_api"
}' https://{site_url}/rest/v11/oauth2/token

More information on authenticating can be found in the How to Authenticate and Log Out example and /oauth2/logout endpoint documentation.

Retrieving Duplicates

Next, we will need to identify the records that are duplicates using the /<module>/duplicateCheck endpoint.

  curl -s -X POST -H OAuth-Token:{access_token} -H Cache-Control:no-cache -H "Content-Type: application/json" -d '{  
    "name":"Test Record"
}' https://{site_url}/rest/v11/Accounts/duplicateCheck

More information on the duplicate check API can be found in the /<module>/duplicateCheck documentation.

Response

The data received from the server is shown below:

  {
    "next_offset": -1,
    "records": [{
        "id": "7f6ea7be-60d6-11e6-8885-a0999b033b33",
        "name": "Test Record",
        "date_entered": "2016-08-12T14:48:25-07:00",
        "date_modified": "2016-08-12T14:48:25-07:00",
        "modified_user_id": "1",
        "modified_by_name": "Administrator",
        "modified_user_link": {
            "full_name": "Administrator",
            "id": "1",
            "_acl": {
                "fields": [],
                "delete": "no",
                "_hash": "8e11bf9be8f04daddee9d08d44ea891e"
            }
        },
        "created_by": "1",
        "created_by_name": "Administrator",
        "created_by_link": {
            "full_name": "Administrator",
            "id": "1",
            "_acl": {
                "fields": [],
                "delete": "no",
                "_hash": "8e11bf9be8f04daddee9d08d44ea891e"
            }
        },
        "description": "Test Data 1",
        "deleted": false,
        "facebook": "",
        "twitter": "",
        "googleplus": "",
        "account_type": "",
        "industry": "",
        "annual_revenue": "",
        "phone_fax": "",
        "billing_address_street": "",
        "billing_address_street_2": "",
        "billing_address_street_3": "",
        "billing_address_street_4": "",
        "billing_address_city": "",
        "billing_address_state": "",
        "billing_address_postalcode": "",
        "billing_address_country": "",
        "rating": "",
        "phone_office": "",
        "phone_alternate": "",
        "website": "",
        "ownership": "",
        "employees": "",
        "ticker_symbol": "",
        "shipping_address_street": "",
        "shipping_address_street_2": "",
        "shipping_address_street_3": "",
        "shipping_address_street_4": "",
        "shipping_address_city": "",
        "shipping_address_state": "",
        "shipping_address_postalcode": "",
        "shipping_address_country": "",
        "parent_id": "",
        "sic_code": "",
        "duns_num": "",
        "parent_name": "",
        "member_of": {
            "name": "",
            "id": "",
            "_acl": {
                "fields": [],
                "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
            }
        },
        "campaign_id": "",
        "campaign_name": "",
        "campaign_accounts": {
            "name": "",
            "id": "",
            "_acl": {
                "fields": [],
                "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
            }
        },
        "following": true,
        "my_favorite": false,
        "tag": [],
        "assigned_user_id": "1",
        "assigned_user_name": "Administrator",
        "assigned_user_link": {
            "full_name": "Administrator",
            "id": "1",
            "_acl": {
                "fields": [],
                "delete": "no",
                "_hash": "8e11bf9be8f04daddee9d08d44ea891e"
            }
        },
        "team_count": "",
        "team_count_link": {
            "team_count": "",
            "id": "1",
            "_acl": {
                "fields": [],
                "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
            }
        },
        "team_name": [{
            "id": "1",
            "name": "Global",
            "name_2": "",
            "primary": true
        }],
        "email": [],
        "email1": "",
        "email2": "",
        "invalid_email": "",
        "email_opt_out": "",
        "email_addresses_non_primary": "",
        "_acl": {
            "fields": {}
        },
        "_module": "Accounts",
        "duplicate_check_rank": 8
    }, {
        "id": "868b4f16-60d6-11e6-bdfc-a0999b033b33",
        "name": "Test Record",
        "date_entered": "2016-08-12T14:48:37-07:00",
        "date_modified": "2016-08-12T14:48:37-07:00",
        "modified_user_id": "1",
        "modified_by_name": "Administrator",
        "modified_user_link": {
            "full_name": "Administrator",
            "id": "1",
            "_acl": {
                "fields": [],
                "delete": "no",
                "_hash": "8e11bf9be8f04daddee9d08d44ea891e"
            }
        },
        "created_by": "1",
        "created_by_name": "Administrator",
        "created_by_link": {
            "full_name": "Administrator",
            "id": "1",
            "_acl": {
                "fields": [],
                "delete": "no",
                "_hash": "8e11bf9be8f04daddee9d08d44ea891e"
            }
        },
        "description": "Test Data 2",
        "deleted": false,
        "facebook": "",
        "twitter": "",
        "googleplus": "",
        "account_type": "",
        "industry": "",
        "annual_revenue": "",
        "phone_fax": "",
        "billing_address_street": "",
        "billing_address_street_2": "",
        "billing_address_street_3": "",
        "billing_address_street_4": "",
        "billing_address_city": "",
        "billing_address_state": "",
        "billing_address_postalcode": "",
        "billing_address_country": "",
        "rating": "",
        "phone_office": "",
        "phone_alternate": "",
        "website": "",
        "ownership": "",
        "employees": "",
        "ticker_symbol": "",
        "shipping_address_street": "",
        "shipping_address_street_2": "",
        "shipping_address_street_3": "",
        "shipping_address_street_4": "",
        "shipping_address_city": "",
        "shipping_address_state": "",
        "shipping_address_postalcode": "",
        "shipping_address_country": "",
        "parent_id": "",
        "sic_code": "",
        "duns_num": "",
        "parent_name": "",
        "member_of": {
            "name": "",
            "id": "",
            "_acl": {
                "fields": [],
                "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
            }
        },
        "campaign_id": "",
        "campaign_name": "",
        "campaign_accounts": {
            "name": "",
            "id": "",
            "_acl": {
                "fields": [],
                "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
            }
        },
        "following": true,
        "my_favorite": false,
        "tag": [],
        "assigned_user_id": "1",
        "assigned_user_name": "Administrator",
        "assigned_user_link": {
            "full_name": "Administrator",
            "id": "1",
            "_acl": {
                "fields": [],
                "delete": "no",
                "_hash": "8e11bf9be8f04daddee9d08d44ea891e"
            }
        },
        "team_count": "",
        "team_count_link": {
            "team_count": "",
            "id": "1",
            "_acl": {
                "fields": [],
                "_hash": "654d337e0e912edaa00dbb0fb3dc3c17"
            }
        },
        "team_name": [{
            "id": "1",
            "name": "Global",
            "name_2": "",
            "primary": true
        }],
        "email": [],
        "email1": "",
        "email2": "",
        "invalid_email": "",
        "email_opt_out": "",
        "email_addresses_non_primary": "",
        "_acl": {
            "fields": {}
        },
        "_module": "Accounts",
        "duplicate_check_rank": 8
    }]
}

Topics