{
    "fields": {
        "name": {
            "type": "varchar",
            "required": true,
            "view": "crm:views/document/fields/name",
            "trim": true
        },
        "file": {
            "type": "file",
            "required": true,
            "view": "crm:views/document/fields/file"
        },
        "status": {
            "type": "enum",
            "options": ["Active", "Draft", "Expired", "Canceled"],
            "view": "views/fields/enum-styled",
            "style": {
                "Canceled": "danger",
                "Expired": "danger"
            }
        },
        "source": {
            "type": "enum",
            "options": ["Espo"],
            "default": "Espo"
        },
        "type": {
            "type": "enum",
            "options": ["", "Contract", "NDA", "EULA", "License Agreement"]
        },
        "publishDate": {
            "type": "date",
            "required": true,
            "default": "javascript: return this.dateTime.getToday();"
        },
        "expirationDate": {
            "type": "date",
            "after": "publishDate"
        },
        "description": {
            "type": "text"
        },
        "createdAt": {
            "type": "datetime",
            "readOnly": true
        },
        "modifiedAt": {
            "type": "datetime",
            "readOnly": true
        },
        "createdBy": {
            "type": "link",
            "readOnly": true,
            "view": "views/fields/user"
        },
        "modifiedBy": {
            "type": "link",
            "readOnly": true,
            "view": "views/fields/user"
        },
        "assignedUser": {
            "type": "link",
            "view": "views/fields/assigned-user"
        },
        "teams": {
            "type": "linkMultiple",
            "view": "views/fields/teams"
        },
        "accounts": {
            "type": "linkMultiple",
            "layoutDetailDisabled": true,
            "layoutListDisabled": true,
            "layoutMassUpdateDisabled": true,
            "importDisabled": true,
            "noLoad": true
        },
        "folder": {
            "type": "link",
            "view": "views/fields/link-category-tree"
        }
    },
    "links": {
        "accounts": {
            "type": "hasMany",
            "entity": "Account",
            "foreign": "documents"
        },
        "opportunities": {
            "type": "hasMany",
            "entity": "Opportunity",
            "foreign": "documents"
        },
        "leads": {
            "type": "hasMany",
            "entity": "Lead",
            "foreign": "documents"
        },
        "contacts": {
            "type": "hasMany",
            "entity": "Contact",
            "foreign": "documents"
        },
        "createdBy": {
            "type": "belongsTo",
            "entity": "User"
        },
        "modifiedBy": {
            "type": "belongsTo",
            "entity": "User"
        },
        "assignedUser": {
            "type": "belongsTo",
            "entity": "User"
        },
        "teams": {
            "type": "hasMany",
            "entity": "Team",
            "relationName": "entityTeam",
            "layoutRelationshipsDisabled": true
        },
        "folder": {
            "type": "belongsTo",
            "foreign": "documents",
            "entity": "DocumentFolder"
        }
    },
    "collection": {
        "sortBy": "createdAt",
        "asc": false
    }
}
