{
    "fields": {
        "name": {
            "type": "varchar",
            "required": true,
            "pattern": "$noBadCharacters"
        },
        "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,
            "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"
        },
        "account": {
            "type": "link"
        },
        "lead": {
            "type": "link"
        },
        "contact": {
            "type": "link",
            "view": "crm:views/case/fields/contact"
        },
        "contacts": {
            "type": "linkMultiple",
            "view": "crm:views/case/fields/contacts",
            "orderBy": "name",
            "detailLayoutIncompatibleFieldList": ["contact"]
        },
        "inboundEmail": {
            "type": "link",
            "readOnly": true
        },
        "originalEmail": {
            "type": "link",
            "notStorable": true,
            "orderDisabled": true,
            "entity": "Email",
            "customizationDisabled": true,
            "layoutAvailabilityList": [],
            "directAccessDisabled": 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"
        },
        "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
        },
        "inboundEmail": {
            "type": "belongsTo",
            "entity": "InboundEmail"
        },
        "account": {
            "type": "belongsTo",
            "entity": "Account",
            "foreign": "cases"
        },
        "lead": {
            "type": "belongsTo",
            "entity": "Lead",
            "foreign": "cases"
        },
        "contact": {
            "type": "belongsTo",
            "entity": "Contact",
            "foreign": "casesPrimary"
        },
        "contacts": {
            "type": "hasMany",
            "entity": "Contact",
            "foreign": "cases",
            "layoutRelationshipsDisabled": true
        },
        "meetings": {
            "type": "hasChildren",
            "entity": "Meeting",
            "foreign": "parent",
            "layoutRelationshipsDisabled": true,
            "audited": true
        },
        "calls": {
            "type": "hasChildren",
            "entity": "Call",
            "foreign": "parent",
            "layoutRelationshipsDisabled": true,
            "audited": true
        },
        "tasks": {
            "type": "hasChildren",
            "entity": "Task",
            "foreign": "parent",
            "layoutRelationshipsDisabled": true,
            "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"]
    },
    "indexes": {
        "status": {
            "columns": ["status", "deleted"]
        },
        "assignedUser": {
            "columns": ["assignedUserId", "deleted"]
        },
        "assignedUserStatus": {
            "columns": ["assignedUserId", "status"]
        }
    }
}
