Document Class Reference
The Document class represents files, bookmarks, snippets, and content stored in the Magentrix Document Library. Documents are organized in folders with support for versioning, social engagement, and security controls.
Overview
The Document class is the metadata layer for files and content in the Document Library. File content is stored in cloud storage, while the Document record tracks properties, location, permissions, and engagement metrics.
Key Characteristics:
- Metadata layer for cloud-stored files
- Support for multiple document types (files, URLs, snippets, etc.)
- Social engagement tracking (views, downloads, likes, ratings)
- Folder-based organization and security
- File content passed via Body field or Load() method
Document vs NoteAndAttachment:
- Document = Content organized in Document Library folders (via FolderId)
- NoteAndAttachment = Content attached to specific records (via ReferenceId)
- Different storage models and visibility in the platform
Document Types
The Type property determines how the document is used and displayed:
| Type | Description | Use Case |
|---|
"File" | Standard file upload | PDFs, Word docs, Excel files, images, etc. |
"URL" | Bookmark to external URL | Quick links to external websites |
"Marketing Link" | URL with merge fields | Personalized links with user data |
"Video" | YouTube or Vimeo link | Embedded video content |
"Email Template" | Email template content | Reusable email templates |
"Note" | Text-based note | Quick notes and documentation |
"Snippet" | Code or configuration file | JavaScript, C#, CSS, JSON, XML, SQL files |
Document Properties Reference
Core Properties
| Property | Type | Required | Description |
|---|
| Id | string | Auto | System-generated unique identifier (read-only) |
| Name | string | Yes | Display name (max 120 characters) |
| UniqueName | string | Recommended | Machine-unique identifier for API calls. Will automatically populate if Document.Load is used. |
| Type | string | No | Document type: "File", "URL", "Marketing Link", "Video", "Email Template", "Note", "Snippet" |
| Body | string | Varies | Transient field for passing content during creation (see details below) |
| Description | string | No | Free-form summary or notes (max 2048 characters) |
| Keywords | string | No | Comma-separated tags for searching (max 3200 characters) |
File-Related Properties
| Property | Type | Required | Description |
|---|
| Extension | string | For files/snippets | File extension without dot (e.g., "pdf", "js", "css") - max 8 characters |
| ContentType | string | Yes | MIME type or "Snippet" (max 80 characters) |
| Size | decimal | Auto | File size in bytes (read-only, max 27 digits) |
Organization Properties
| Property | Type | Required | Description |
|---|
| FolderId | string | Yes | Parent folder ID (controls security and organization) |
| Folder | Folder | Auto | Parent folder object (navigation property, read-only) |
| AuthorId | string | Recommended | User ID of document author |
URL and Link Properties
| Property | Type | Required | Description |
|---|
| URL | string | For URLs | External URL for bookmarks and marketing links (max 512 characters) |
Publishing and Sharing
| Property | Type | Required | Description |
|---|
| Published | bool | No | If true, document is publicly accessible via direct link without authentication (default: false) |
| EnableCoBranding | bool | No | Allows document to be co-branded by partners |
Social Engagement Metrics
| Property | Type | Required | Description |
|---|
| DownloadCount | decimal | Auto | Total downloads (read-only) |
| ViewCount | decimal | Auto | Total views (read-only) |
| LikeCount | decimal | Auto | Total likes (read-only) |
| FeedCount | decimal | Auto | Number of comments/feed items (read-only) |
| RatingCount | decimal | Auto | Number of ratings submitted (read-only) |
| RatingScore | decimal | Auto | Average rating value (read-only) |
Advanced Properties
| Property | Type | Required | Description |
|---|
| TileImageName | string | No | Thumbnail filename for tile view (max 50 characters) |
System Fields
| Property | Type | Required | Description |
|---|
| CreatedOn | DateTime | Auto | Record creation timestamp (read-only) |
| CreatedById | string | Auto | User ID who created the record (read-only) |
| ModifiedOn | DateTime | Auto | Last modification timestamp (read-only) |
| ModifiedById | string | Auto | User ID who last modified (read-only) |
| IsDeleted | bool | Auto | Soft-delete flag for recycle bin (read-only) |
Static Methods Reference
| Method | Return Type | Description |
|---|
| Load(HttpPostedFile file) | Document | Creates Document from uploaded file with properties auto-populated |
| GetUniqueName(string name, string extension) | string | Generates unique name with timestamp for file identification |
Method Details
Load
Static method that creates a Document object from an uploaded file with properties automatically populated.
Signature:
static Document Load(HttpPostedFile file)
Parameters:
file (HttpPostedFile, required) - The uploaded file from HTTP request
Returns:
- Document object with auto-populated properties, or null if file is empty
Auto-Populated Properties:
Type - Set to "File"Name - Original filenameContentType - File's MIME typeExtension - File extension without dotBody - Base64-encoded file content (transient)Size - File size in bytes
Properties You Must Set:
FolderId - Parent folder IDAuthorId - Typically set to SystemInfo.UserId
GetUniqueName
Static method that generates a unique document name by combining name and timestamp.
Signature:
static string GetUniqueName(string name, string extension)
Parameters:
name (string, required) - Base document nameextension (string, required) - File extension without dot
Returns:
- Unique name string with sanitized name and timestamp
Description: Ensures document names are unique within the system by combining the document name with a timestamp. The method sanitizes the name and appends a timestamp to prevent naming conflicts. This method should only be used to get the unique name if Document.Load is not called.
Property Details
Body
Transient field for passing content during document creation. Content is stored in cloud storage, not persisted in the database.
Type: string
Required: Depends on Type
Persisted: No - transient only
Description: The Body field is used to pass content to the platform during document creation. The platform processes this content and stores it in cloud storage. After creation, Body does not contain the content - it must be retrieved via download URLs.
Usage by Document Type:
For File Uploads (Type = "File"):
- Pass Base64-encoded file content during creation
- Alternative to Document.Load() method
- Content stored in cloud storage after insert
- Body is null after creation
For Bookmarks (Type = "URL"):
- Pass the URL string during creation
- URL stored in cloud storage after insert
- Body is null after creation
For Marketing Links (Type = "Marketing Link"):
- Pass URL with merge fields during creation
- URL stored in cloud storage after insert
- Body is null after creation
- Merge fields processed on retrieval
For Notes (Type = "Note"):
- Pass note text content during creation
- Content stored in cloud storage after insert
- Body is null after creation
For Snippets (Type = "Snippet"):
- Pass snippet code/text during creation
- Can be Base64-encoded or plain text
- Content stored in cloud storage after insert
- Body is null after creation
- Used with Extension field to define snippet type
Important Notes:
- Body is a write-only field during creation
- Never query Body expecting content back
- Content retrieval uses download URLs
- Body does not persist to database
Extension
File extension or snippet type identifier.
Type: string
Required: For files and snippets
Max Length: 8 characters
Usage:
For File Documents:
- File extension without dot: "pdf", "docx", "jpg"
- Determines file type and icon display
- Used for content type mapping
For Snippet Documents:
- Snippet language/type: "js", "css", "html", "cs", "sql", "xml", "json"
- Defines syntax highlighting and editor behavior
- Used for snippet categorization
Common Snippet Extensions:
"js" - JavaScript snippets"cs" - C# code snippets"css" - CSS style snippets"html" - HTML markup snippets"sql" - SQL query snippets"xml" - XML configuration snippets"json" - JSON data snippets"ts" - TypeScript snippets"py" - Python snippets"yaml" or "yml" - YAML configuration
ContentType
MIME type or content identifier for the document.
Type: string
Required: Yes
Max Length: 80 characters
Description: Specifies the MIME type for files or content type identifier for non-file documents.
For File Documents:
- Standard MIME types: "application/pdf", "image/png", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
- Used by browsers to determine handling behavior
For Snippet Documents:
- Set to
"Snippet" (string literal) - Identifies document as code snippet
- Works with Extension field for snippet type
Common MIME Types:
"application/pdf" - PDF documents"application/vnd.openxmlformats-officedocument.wordprocessingml.document" - Word (.docx)"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" - Excel (.xlsx)"image/png" - PNG images"image/jpeg" - JPEG images"text/plain" - Text files"application/json" - JSON files"text/css" - CSS files"application/javascript" - JavaScript files
Type
Document type identifier.
Type: string
Required: No (defaults to "File")
Valid Values:
"File" - Standard file upload"URL" - Bookmark to external URL"Marketing Link" - URL with merge fields"Video" - YouTube or Vimeo link"Email Template" - Email template content"Note" - Text-based note"Snippet" - Code or configuration file
Description: The Type property determines how the document is interpreted, displayed, and processed by the platform.
FolderId
ID of the parent folder containing this document.
Type: string
Required: Yes
Description: Links the document to a specific folder in the Document Library. Folder membership controls security, visibility, and organization.
Usage:
- Must reference valid Folder.Id
- Cannot be null or empty
- Folder permissions control document access
- Documents inherit folder sharing settings
AuthorId
User ID of the document author.
Type: string
Required: Recommended
Description: Identifies the user who authored or uploaded the document. Used for attribution and tracking.
Best Practice: Set to SystemInfo.UserId during document creation for proper author tracking.
Published
Controls whether the document is publicly accessible via direct link.
Type: bool
Required: No
Default: false
Description: When set to true, the document becomes publicly available to anyone with the direct link, regardless of authentication status or folder permissions. This enables public file sharing without requiring users to log into the portal.
⚠️ WARNING: Setting Published = true makes the document accessible to ANYONE with the link, including unauthenticated users. Only enable this for content intended for public consumption. Do not use for confidential, sensitive, or internal-only documents.
Public Access Behavior:
- When Published = true: Anyone with the document URL can access the file
- When Published = false: Only authenticated users with appropriate folder permissions can access the file
Usage:
- Set to true for publicly accessible content (marketing materials, public resources, external documentation)
- Set to false for internal documents requiring authentication
- Works independently of folder sharing settings
- Guest user access requires Published = true
Security Considerations:
- Published documents are accessible without login
- Document URLs can be shared freely
- No folder permissions are enforced when Published = true
- Consider content sensitivity before enabling
URL
External URL for bookmarks and marketing links.
Type: string
Required: For Type = "URL" or "Marketing Link"
Max Length: 512 characters
Description: Contains the URL for bookmark documents or URL with merge fields for marketing links.
For Bookmarks:
- Static URL: "https://example.com/resource"
- Must be valid URL format
For Marketing Links:
- Dynamic URL with merge fields: "https://example.com?user={!User.Email}"
- Merge fields processed per user viewing the link
Size
File size in bytes.
Type: decimal
Required: Auto-calculated
Read-Only: Yes
Description: Automatically calculated file size based on uploaded content. Used for storage tracking and display.
Snippet Creation (Type = "Snippet")
Snippets are code files and configuration content organized in the Document Library.
Required Properties for Snippets:
Name - Snippet filename (e.g., "validation.js")Extension - File type: "js", "css", "html", "cs", "sql", "xml", "json"Body - Code content (Base64 or plain text)ContentType - Set to "Snippet"Type - Set to "Snippet"FolderId - Parent folder IDAuthorId - Set to SystemInfo.UserId
Common Snippet Types:
- JavaScript (.js) - Client-side scripts
- C# (.cs) - Server-side code samples
- CSS (.css) - Stylesheet snippets
- JSON (.json) - Configuration files
- XML (.xml) - Configuration and data files
- SQL (.sql) - Database queries
- HTML (.html) - Markup fragments
- TypeScript (.ts) - TypeScript code
- Python (.py) - Python scripts
- YAML (.yaml/.yml) - YAML configurations
Related Topics