{
    "fields": {
        "name": {
            "type": "personName"
        },
        "salutationName": {
            "type": "enum",
            "options": ["", "Mr.", "Mrs.", "Ms.", "Dr."]
        },
        "firstName": {
            "type": "varchar",
            "maxLength": 100,
            "default":""
        },
        "lastName": {
            "type": "varchar",
            "maxLength": 100,
            "required": true,
            "default":""
        },
        "accountId": {
            "where": {
                "=": "contact.id IN (SELECT contact_id FROM account_contact WHERE deleted = 0 AND account_id = {value})"
            },
            "disabled": true
        },
        "title": {
            "type": "varchar",
            "maxLength": 50,
            "notStorable": true,
            "select": "accountContact.role",
            "orderBy": "accountContact.role {direction}",
            "where": {
                "LIKE": "contact.id IN (SELECT contact_id FROM account_contact WHERE deleted = 0 AND role LIKE {value})",
                "=": "contact.id IN (SELECT contact_id FROM account_contact WHERE deleted = 0 AND role = {value})"
            }
        },
        "description": {
            "type": "text"
        },
        "emailAddress": {
            "type": "email"
        },
        "phoneNumber": {
            "type": "phone",
            "typeList": ["Mobile", "Office", "Home", "Fax", "Other"],
            "defaultType": "Mobile"
        },
        "doNotCall": {
            "type": "bool"
        },
        "address": {
            "type": "address"
        },
        "addressStreet": {
            "type": "text",
            "maxLength": 255,
            "dbType": "varchar"
        },
        "addressCity": {
            "type": "varchar"
        },
        "addressState": {
            "type": "varchar"
        },
        "addressCountry": {
            "type": "varchar"
        },
        "addressPostalCode": {
            "type": "varchar"
        },
        "account": {
            "type": "link"
        },
        "accounts": {
            "type": "linkMultiple",
            "view": "Crm:Contact.Fields.Accounts",
            "columns": {
                "role": "contactRole"
            }
        },
        "accountRole": {
            "type": "varchar",
            "notStorable": true,
            "disabled": true
        },
        "accountType": {
            "type": "foreign",
            "link": "account",
            "field": "type"
        },
        "opportunityRole": {
            "type": "enum",
            "notStorable": true,
            "disabled": true,
            "options": ["", "Decision Maker", "Evaluator", "Influencer"]
        },
        "acceptanceStatus": {
            "type": "varchar",
            "notStorable": true,
            "disabled": true
        },
        "campaign": {
            "type": "link",
            "layoutListDisabled": true
        },
        "createdAt": {
            "type": "datetime",
            "readOnly": true
        },
        "modifiedAt": {
            "type": "datetime",
            "readOnly": true
        },
        "createdBy": {
            "type": "link",
            "readOnly": true
        },
        "modifiedBy": {
            "type": "link",
            "readOnly": true
        },
        "assignedUser": {
            "type": "link"
        },
        "teams": {
            "type": "linkMultiple"
        },
        "targetLists": {
            "type": "linkMultiple",
            "layoutDetailDisabled": true,
            "layoutListDisabled": true,
            "layoutMassUpdateDisabled": true,
            "importDisabled": true,
            "noLoad": true
        },
        "targetList": {
            "type": "link",
            "notStorable": true,
            "layoutDetailDisabled": true,
            "layoutListDisabled": true,
            "layoutMassUpdateDisabled": true,
            "layoutFiltersDisabled": true,
            "entity": "TargetList"
        }
    },
    "links": {
        "createdBy": {
            "type": "belongsTo",
            "entity": "User"
        },
        "modifiedBy": {
            "type": "belongsTo",
            "entity": "User"
        },
        "assignedUser": {
            "type": "belongsTo",
            "entity": "User"
        },
        "teams": {
            "type": "hasMany",
            "entity": "Team",
            "relationName": "entityTeam",
            "layoutRelationshipsDisabled": true
        },
        "account": {
            "type": "belongsTo",
            "entity": "Account"
        },
        "accounts": {
            "type": "hasMany",
            "entity": "Account",
            "foreign": "contacts",
            "additionalColumns": {
                "role": {
                    "type": "varchar",
                    "len": 50
                }
            },
            "layoutRelationshipsDisabled": true
        },
        "opportunities": {
            "type": "hasMany",
            "entity": "Opportunity",
            "foreign": "contacts"
        },
        "casesPrimary": {
            "type": "hasMany",
            "entity": "Case",
            "foreign": "contact",
            "layoutRelationshipsDisabled": true
        },
        "cases": {
            "type": "hasMany",
            "entity": "Case",
            "foreign": "contacts"
        },
        "meetings": {
            "type": "hasMany",
            "entity": "Meeting",
            "foreign": "contacts",
            "layoutRelationshipsDisabled": true
        },
        "calls": {
            "type": "hasMany",
            "entity": "Call",
            "foreign": "contacts",
            "layoutRelationshipsDisabled": true
        },
        "tasks": {
            "type": "hasChildren",
            "entity": "Task",
            "foreign": "parent",
            "layoutRelationshipsDisabled": true
        },
        "emails": {
            "type": "hasChildren",
            "entity": "Email",
            "foreign": "parent",
            "layoutRelationshipsDisabled": true
        },
        "campaign": {
            "type": "belongsTo",
            "entity": "Campaign",
            "foreign": "contacts",
            "noJoin": true
        },
        "campaignLogRecords": {
            "type": "hasChildren",
            "entity": "CampaignLogRecord",
            "foreign": "parent"
        },
        "targetLists": {
            "type": "hasMany",
            "entity": "TargetList",
            "foreign": "contacts"
        }
    },
    "collection": {
        "sortBy": "name",
        "asc": true
    },
    "indexes": {
        "firstName": {
            "columns": ["firstName", "deleted"]
        },
        "name": {
            "columns": ["firstName", "lastName"]
        },
        "assignedUser": {
            "columns": ["assignedUserId", "deleted"]
        }
    }
}
