{
    "fields": {
        "name": {
            "type": "personName",
            "isPersonalData": true
        },
        "salutationName": {
            "type": "enum",
            "options": ["", "Mr.", "Ms.", "Mrs.", "Dr."]
        },
        "firstName": {
            "type": "varchar",
            "maxLength": 100
        },
        "lastName": {
            "type": "varchar",
            "maxLength": 100,
            "required": true
        },
        "accountAnyId": {
            "notStorable": true,
            "orderDisabled": true,
            "customizationDisabled": true,
            "utility": true,
            "type": "varchar",
            "where": {
                "=": {
                    "whereClause": {
                        "id=s": {
                            "from": "AccountContact",
                            "select": ["contactId"],
                            "whereClause": {
                                "deleted": false,
                                "accountId": "{value}"
                            }
                        }
                    }
                },
                "<>": {
                    "whereClause": {
                        "id!=s": {
                            "from": "AccountContact",
                            "select": ["contactId"],
                            "whereClause": {
                                "deleted": false,
                                "accountId": "{value}"
                            }
                        }
                    }
                },
                "IN": {
                    "whereClause": {
                        "id=s": {
                            "from": "AccountContact",
                            "select": ["contactId"],
                            "whereClause": {
                                "deleted": false,
                                "accountId": "{value}"
                            }
                        }
                    }
                },
                "NOT IN": {
                    "whereClause": {
                        "id!=s": {
                            "from": "AccountContact",
                            "select": ["contactId"],
                            "whereClause": {
                                "deleted": false,
                                "accountId": "{value}"
                            }
                        }
                    }
                },
                "IS NULL": {
                    "whereClause": {
                        "accountId": null
                    }
                },
                "IS NOT NULL": {
                    "whereClause": {
                        "accountId!=": null
                    }
                }
            }
        },
        "title": {
            "type": "varchar",
            "maxLength": 100,
            "view": "crm:views/contact/fields/title",
            "directUpdateDisabled": true,
            "notStorable": true,
            "select": {
                "select": "accountContactPrimary.role",
                "leftJoins": [
                    [
                        "AccountContact",
                        "accountContactPrimary",
                        {
                            "contact.id:": "accountContactPrimary.contactId",
                            "contact.accountId:": "accountContactPrimary.accountId",
                            "accountContactPrimary.deleted": false
                        }
                    ]
                ]
            },
            "order": {
                "order": [
                    ["accountContactPrimary.role", "{direction}"]
                ],
                "leftJoins": [
                    [
                        "AccountContact",
                        "accountContactPrimary",
                        {
                            "contact.id:": "accountContactPrimary.contactId",
                            "contact.accountId:": "accountContactPrimary.accountId",
                            "accountContactPrimary.deleted": false
                        }
                    ]
                ]
            },
            "where": {
                "LIKE": {
                    "whereClause": {
                        "id=s": {
                            "from": "AccountContact",
                            "select": ["contactId"],
                            "whereClause": {
                                "deleted": false,
                                "role*": "{value}"
                            }
                        }
                    }
                },
                "NOT LIKE": {
                    "whereClause": {
                        "id!=s": {
                            "from": "AccountContact",
                            "select": ["contactId"],
                            "whereClause": {
                                "deleted": false,
                                "role*": "{value}"
                            }
                        }
                    }
                },
                "=": {
                    "whereClause": {
                        "id=s": {
                            "from": "AccountContact",
                            "select": ["contactId"],
                            "whereClause": {
                                "deleted": false,
                                "role": "{value}"
                            }
                        }
                    }
                },
                "<>": {
                    "whereClause": {
                        "id!=s": {
                            "from": "AccountContact",
                            "select": ["contactId"],
                            "whereClause": {
                                "deleted": false,
                                "role": "{value}"
                            }
                        }
                    }
                },
                "IS NULL": {
                    "whereClause": {
                        "NOT": {
                            "EXISTS": {
                                "from": "Contact",
                                "fromAlias": "sq",
                                "select": ["id"],
                                "leftJoins": [
                                    [
                                        "accounts",
                                        "m",
                                        {},
                                        {"onlyMiddle": true}
                                    ]
                                ],
                                "whereClause": {
                                    "AND": [
                                        {"m.role!=": null},
                                        {"m.role!=": ""},
                                        {"sq.id:": "contact.id"}
                                    ]
                                }
                            }
                        }
                    }
                },
                "IS NOT NULL": {
                    "whereClause": {
                        "EXISTS": {
                            "from": "Contact",
                            "fromAlias": "sq",
                            "select": ["id"],
                            "leftJoins": [
                                [
                                    "accounts",
                                    "m",
                                    {},
                                    {"onlyMiddle": true}
                                ]
                            ],
                            "whereClause": {
                                "AND": [
                                    {"m.role!=": null},
                                    {"m.role!=": ""},
                                    {"sq.id:": "contact.id"}
                                ]
                            }
                        }
                    }
                }
            },
            "customizationOptionsDisabled": true,
            "textFilterDisabled": true,
            "importEnabled": true
        },
        "description": {
            "type": "text"
        },
        "emailAddress": {
            "type": "email",
            "isPersonalData": true
        },
        "phoneNumber": {
            "type": "phone",
            "typeList": ["Mobile", "Office", "Home", "Fax", "Other"],
            "defaultType": "Mobile",
            "isPersonalData": true
        },
        "doNotCall": {
            "type": "bool"
        },
        "address": {
            "type": "address",
            "isPersonalData": true
        },
        "addressStreet": {
            "type": "text",
            "maxLength": 255,
            "dbType": "varchar"
        },
        "addressCity": {
            "type": "varchar"
        },
        "addressState": {
            "type": "varchar"
        },
        "addressCountry": {
            "type": "varchar"
        },
        "addressPostalCode": {
            "type": "varchar"
        },
        "account": {
            "type": "link",
            "view": "crm:views/contact/fields/account"
        },
        "accounts": {
            "type": "linkMultiple",
            "view": "crm:views/contact/fields/accounts",
            "columns": {
                "role": "contactRole",
                "isInactive": "contactIsInactive"
            },
            "additionalAttributeList": ["columns"],
            "orderBy": "name",
            "detailLayoutIncompatibleFieldList": ["account"]
        },
        "accountRole": {
            "type": "varchar",
            "notStorable": true,
            "orderDisabled": true,
            "directUpdateDisabled": true,
            "layoutDetailDisabled": true,
            "layoutMassUpdateDisabled": true,
            "layoutFiltersDisabled": true,
            "layoutAvailabilityList": ["listForAccount"],
            "exportDisabled": true,
            "importDisabled": true,
            "view": "crm:views/contact/fields/account-role",
            "customizationOptionsDisabled": true,
            "textFilterDisabled": true
        },
        "accountIsInactive": {
            "type": "bool",
            "notStorable": true,
            "mergeDisabled": true,
            "foreignAccessDisabled": true,
            "select": {
                "select": "accountContactPrimary.isInactive",
                "leftJoins": [
                    [
                        "AccountContact",
                        "accountContactPrimary",
                        {
                            "contact.id:": "accountContactPrimary.contactId",
                            "contact.accountId:": "accountContactPrimary.accountId",
                            "accountContactPrimary.deleted": false
                        }
                    ]
                ]
            },
            "order": {
                "order": [
                    ["accountContactPrimary.isInactive", "{direction}"]
                ],
                "leftJoins": [
                    [
                        "AccountContact",
                        "accountContactPrimary",
                        {
                            "contact.id:": "accountContactPrimary.contactId",
                            "contact.accountId:": "accountContactPrimary.accountId",
                            "accountContactPrimary.deleted": false
                        }
                    ]
                ]
            },
            "where": {
                "= TRUE": {
                    "leftJoins": [
                        [
                            "AccountContact",
                            "accountContactFilterIsInactive",
                            {
                                "accountContactFilterIsInactive.contactId:": "id",
                                "accountContactFilterIsInactive.accountId:": "accountId",
                                "accountContactFilterIsInactive.deleted": false
                            }
                        ]
                    ],
                    "whereClause": {
                        "accountContactFilterIsInactive.isInactive": true
                    }
                },
                "= FALSE": {
                    "leftJoins": [
                        [
                            "AccountContact",
                            "accountContactFilterIsInactive",
                            {
                                "accountContactFilterIsInactive.contactId:": "id",
                                "accountContactFilterIsInactive.accountId:": "accountId",
                                "accountContactFilterIsInactive.deleted": false
                            }
                        ]
                    ],
                    "whereClause": {
                        "OR": [
                            {
                                "accountContactFilterIsInactive.isInactive!=": true
                            },
                            {
                                "accountContactFilterIsInactive.isInactive=": null
                            }
                        ]
                    }
                }
            },
            "layoutListDisabled": true,
            "layoutDetailDisabled": true,
            "layoutMassUpdateDisabled": true
        },
        "accountType": {
            "type": "foreign",
            "link": "account",
            "field": "type",
            "readOnly": true,
            "view": "views/fields/foreign-enum"
        },
        "opportunityRole": {
            "type": "enum",
            "notStorable": true,
            "orderDisabled": true,
            "options": ["", "Decision Maker", "Evaluator", "Influencer"],
            "layoutMassUpdateDisabled": true,
            "layoutListDisabled": true,
            "layoutDetailDisabled": true,
            "customizationRequiredDisabled": true,
            "customizationIsSortedDisabled": true,
            "customizationAuditedDisabled": true,
            "customizationReadOnlyDisabled": true,
            "converterClassName": "Espo\\Classes\\FieldConverters\\RelationshipRole",
            "converterData": {
                "column": "role",
                "link": "opportunities",
                "relationName": "contactOpportunity",
                "nearKey": "contactId"
            },
            "directUpdateDisabled": true,
            "view": "crm:views/contact/fields/opportunity-role"
        },
        "acceptanceStatus": {
            "type": "varchar",
            "notStorable": true,
            "orderDisabled": true,
            "exportDisabled": true,
            "utility": true,
            "fieldManagerParamList": []
        },
        "acceptanceStatusMeetings": {
            "type": "enum",
            "notStorable": true,
            "orderDisabled": true,
            "directAccessDisabled": true,
            "filtersEnabled": true,
            "directUpdateDisabled": true,
            "layoutAvailabilityList": ["filters"],
            "importDisabled": true,
            "exportDisabled": true,
            "view": "crm:views/lead/fields/acceptance-status",
            "link": "meetings",
            "column": "status",
            "fieldManagerParamList": []
        },
        "acceptanceStatusCalls": {
            "type": "enum",
            "notStorable": true,
            "orderDisabled": true,
            "directUpdateDisabled": true,
            "directAccessDisabled": true,
            "filtersEnabled": true,
            "layoutAvailabilityList": ["filters"],
            "importDisabled": true,
            "exportDisabled": true,
            "view": "crm:views/lead/fields/acceptance-status",
            "link": "calls",
            "column": "status",
            "fieldManagerParamList": []
        },
        "campaign": {
            "type": "link"
        },
        "createdAt": {
            "type": "datetime",
            "readOnly": true,
            "fieldManagerParamList": [
                "useNumericFormat"
            ]
        },
        "modifiedAt": {
            "type": "datetime",
            "readOnly": true,
            "fieldManagerParamList": [
                "useNumericFormat"
            ]
        },
        "createdBy": {
            "type": "link",
            "readOnly": true,
            "view": "views/fields/user",
            "fieldManagerParamList": []
        },
        "modifiedBy": {
            "type": "link",
            "readOnly": true,
            "view": "views/fields/user",
            "fieldManagerParamList": []
        },
        "assignedUser": {
            "type": "link",
            "view": "views/fields/assigned-user"
        },
        "teams": {
            "type": "linkMultiple",
            "view": "views/fields/teams"
        },
        "targetLists": {
            "type": "linkMultiple",
            "layoutDetailDisabled": true,
            "layoutListDisabled": true,
            "importDisabled": true,
            "directAccessDisabled": true,
            "filtersEnabled": true,
            "directUpdateEnabled": true,
            "noLoad": true
        },
        "targetList": {
            "type": "link",
            "notStorable": true,
            "orderDisabled": true,
            "layoutDetailDisabled": true,
            "layoutListDisabled": true,
            "layoutMassUpdateDisabled": true,
            "layoutFiltersDisabled": true,
            "exportDisabled": true,
            "entity": "TargetList",
            "directAccessDisabled": true,
            "importEnabled": true
        },
        "portalUser": {
            "type": "linkOne",
            "readOnly": true,
            "notStorable": true,
            "view": "views/fields/link-one"
        },
        "hasPortalUser": {
            "type": "bool",
            "notStorable": true,
            "readOnly": true,
            "mergeDisabled": true,
            "customizationDefaultDisabled": true,
            "customizationReadOnlyDisabled": true,
            "foreignAccessDisabled": true,
            "select": {
                "select": "IS_NOT_NULL:(portalUser.id)",
                "leftJoins": [["portalUser", "portalUser"]]
            },
            "where": {
                "= TRUE": {
                    "whereClause": {
                        "portalUser.id!=": null
                    },
                    "leftJoins": [["portalUser", "portalUser"]]
                },
                "= FALSE": {
                    "whereClause": {
                        "portalUser.id=": null
                    },
                    "leftJoins": [["portalUser", "portalUser"]]
                }
            },
            "order": {
                "order": [
                    ["portalUser.id", "{direction}"]
                ],
                "leftJoins": [["portalUser", "portalUser"]],
                "additionalSelect": ["portalUser.id"]
            }
        },
        "originalLead": {
            "type": "linkOne",
            "readOnly": true,
            "view": "views/fields/link-one"
        },
        "targetListIsOptedOut": {
            "type": "bool",
            "notStorable": true,
            "orderDisabled": true,
            "readOnly": true,
            "utility": true
        },
        "originalEmail": {
            "type": "link",
            "notStorable": true,
            "orderDisabled": true,
            "entity": "Email",
            "customizationDisabled": true,
            "layoutAvailabilityList": [],
            "directAccessDisabled": true
        }
    },
    "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",
            "deferredLoad": true
        },
        "accounts": {
            "type": "hasMany",
            "entity": "Account",
            "foreign": "contacts",
            "additionalColumns": {
                "role": {
                    "type": "varchar",
                    "len": 100
                },
                "isInactive": {
                    "type": "bool",
                    "default": false
                }
            },
            "additionalAttributeList": ["columns"],
            "layoutRelationshipsDisabled": true,
            "columnAttributeMap": {
                "role": "accountRole",
                "isInactive": "accountIsInactive"
            }
        },
        "opportunities": {
            "type": "hasMany",
            "entity": "Opportunity",
            "foreign": "contacts",
            "columnAttributeMap": {
                "role": "opportunityRole"
            }
        },
        "opportunitiesPrimary": {
            "type": "hasMany",
            "entity": "Opportunity",
            "foreign": "contact",
            "layoutRelationshipsDisabled": true
        },
        "casesPrimary": {
            "type": "hasMany",
            "entity": "Case",
            "foreign": "contact",
            "layoutRelationshipsDisabled": true
        },
        "cases": {
            "type": "hasMany",
            "entity": "Case",
            "foreign": "contacts"
        },
        "meetings": {
            "type": "hasMany",
            "entity": "Meeting",
            "foreign": "contacts",
            "audited": true,
            "columnAttributeMap": {
                "status": "acceptanceStatus"
            }
        },
        "calls": {
            "type": "hasMany",
            "entity": "Call",
            "foreign": "contacts",
            "audited": true,
            "columnAttributeMap": {
                "status": "acceptanceStatus"
            }
        },
        "meetingsChildren": {
            "type": "hasChildren",
            "entity": "Meeting",
            "foreign": "parent",
            "readOnly": true
        },
        "callsChildren": {
            "type": "hasChildren",
            "entity": "Call",
            "foreign": "parent",
            "readOnly": true
        },
        "tasks": {
            "type": "hasChildren",
            "entity": "Task",
            "foreign": "parent",
            "audited": true
        },
        "emails": {
            "type": "hasChildren",
            "entity": "Email",
            "foreign": "parent",
            "layoutRelationshipsDisabled": true
        },
        "campaign": {
            "type": "belongsTo",
            "entity": "Campaign",
            "foreign": "contacts"
        },
        "campaignLogRecords": {
            "type": "hasChildren",
            "entity": "CampaignLogRecord",
            "foreign": "parent"
        },
        "targetLists": {
            "type": "hasMany",
            "entity": "TargetList",
            "foreign": "contacts",
            "columnAttributeMap": {
                "optedOut": "targetListIsOptedOut"
            }
        },
        "portalUser": {
            "type": "hasOne",
            "entity": "User",
            "foreign": "contact"
        },
        "originalLead": {
            "type": "hasOne",
            "entity": "Lead",
            "foreign": "createdContact"
        },
        "documents": {
            "type": "hasMany",
            "entity": "Document",
            "foreign": "contacts",
            "audited": true
        },
        "tasksPrimary": {
            "type": "hasMany",
            "entity": "Task",
            "foreign": "contact",
            "layoutRelationshipsDisabled": true
        }
    },
    "collection": {
        "orderBy": "createdAt",
        "order": "desc",
        "textFilterFields": ["name", "emailAddress"]
    },
    "indexes": {
        "createdAt": {
            "columns": ["createdAt", "deleted"]
        },
        "createdAtId": {
            "unique": true,
            "columns": ["createdAt", "id"]
        },
        "firstName": {
            "columns": ["firstName", "deleted"]
        },
        "name": {
            "columns": ["firstName", "lastName"]
        },
        "assignedUser": {
            "columns": ["assignedUserId", "deleted"]
        }
    }
}
