{
    "fields": {
        "name": {
            "type": "varchar",
            "required": true,
            "pattern": "$noBadCharacters",
            "audited": true
        },
        "number": {
            "type": "autoincrement",
            "index": true
        },
        "status": {
            "type": "enum",
            "options": ["New", "Assigned", "Pending", "Closed", "Rejected", "Duplicate"],
            "default": "New",
            "style": {
                "Closed": "success",
                "Assigned": "primary",
                "Duplicate": "info",
                "Pending": "warning",
                "Rejected": "info"
            },
            "audited": true,
            "displayAsLabel": true,
            "labelType": "state",
            "fieldManagerAdditionalParamList": [
                {
                    "name": "notActualOptions",
                    "view": "views/admin/field-manager/fields/not-actual-options"
                }
            ],
            "notActualOptions": ["Closed", "Rejected", "Duplicate"],
            "customizationOptionsReferenceDisabled": true
        },
        "priority": {
            "type": "enum",
            "options": ["Low", "Normal", "High", "Urgent"],
            "default": "Normal",
            "displayAsLabel": true,
            "style": {
                "High": "warning",
                "Urgent": "danger"
            },
            "audited": true,
            "customizationOptionsReferenceDisabled": true
        },
        "type": {
            "type": "enum",
            "options": ["", "Question", "Incident", "Problem"],
            "audited": true,
            "customizationOptionsReferenceDisabled": true
        },
        "description": {
            "type": "text",
            "preview": true,
            "attachmentField": "attachments",
            "cutHeight": 500
        },
        "account": {
            "type": "link",
            "audited": true
        },
        "lead": {
            "type": "link"
        },
        "contact": {
            "type": "link"
        },
        "contacts": {
            "type": "linkMultiple",
            "view": "views/fields/link-multiple-with-primary",
            "orderBy": "name",
            "detailLayoutIncompatibleFieldList": ["contact"],
            "primaryLink": "contact",
            "audited": true
        },
        "inboundEmail": {
            "type": "link",
            "readOnly": true
        },
        "originalEmail": {
            "type": "link",
            "notStorable": true,
            "orderDisabled": true,
            "entity": "Email",
            "customizationDisabled": true,
            "layoutAvailabilityList": [],
            "directAccessDisabled": true
        },
        "isInternal": {
            "type": "bool",
            "audited": true
        },
        "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"
        },
        "collaborators": {
            "type": "linkMultiple",
            "view": "views/fields/collaborators",
            "maxCount": 30,
            "fieldManagerParamList": [
                "readOnly",
                "readOnlyAfterCreate",
                "audited",
                "autocompleteOnEmpty",
                "maxCount",
                "inlineEditDisabled",
                "tooltipText"
            ],
            "dynamicLogicVisibleDisabled": true
        },
        "attachments": {
            "type": "attachmentMultiple"
        }
    },
    "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
        },
        "collaborators": {
            "type": "hasMany",
            "entity": "User",
            "relationName": "entityCollaborator",
            "layoutRelationshipsDisabled": true
        },
        "inboundEmail": {
            "type": "belongsTo",
            "entity": "InboundEmail"
        },
        "account": {
            "type": "belongsTo",
            "entity": "Account",
            "foreign": "cases",
            "deferredLoad": true
        },
        "lead": {
            "type": "belongsTo",
            "entity": "Lead",
            "foreign": "cases",
            "deferredLoad": true
        },
        "contact": {
            "type": "belongsTo",
            "entity": "Contact",
            "foreign": "casesPrimary",
            "deferredLoad": true
        },
        "contacts": {
            "type": "hasMany",
            "entity": "Contact",
            "foreign": "cases",
            "layoutRelationshipsDisabled": true
        },
        "meetings": {
            "type": "hasChildren",
            "entity": "Meeting",
            "foreign": "parent",
            "audited": true
        },
        "calls": {
            "type": "hasChildren",
            "entity": "Call",
            "foreign": "parent",
            "audited": true
        },
        "tasks": {
            "type": "hasChildren",
            "entity": "Task",
            "foreign": "parent",
            "audited": true
        },
        "emails": {
            "type": "hasChildren",
            "entity": "Email",
            "foreign": "parent",
            "layoutRelationshipsDisabled": true
        },
        "articles": {
            "type": "hasMany",
            "entity": "KnowledgeBaseArticle",
            "foreign": "cases",
            "audited": true
        }
    },
    "collection": {
        "orderBy": "number",
        "order": "desc",
        "textFilterFields": ["name", "number", "description"],
        "fullTextSearch": true
    },
    "indexes": {
        "status": {
            "columns": ["status", "deleted"]
        },
        "assignedUser": {
            "columns": ["assignedUserId", "deleted"]
        },
        "assignedUserStatus": {
            "columns": ["assignedUserId", "status"]
        }
    },
    "optimisticConcurrencyControl": true
}
