Table of Contents


NoteAndAttachment Class Reference

The NoteAndAttachment class represents notes, file attachments, bookmarks, and code snippets that can be linked to any record in the Magentrix platform. This class provides a unified way to attach content to entities such as Accounts, Contacts, Opportunities, and custom entities.


Overview

The NoteAndAttachment class is used to create four types of content attached to records:

  • Notes - Text-based notes and comments
  • File Attachments - Files attached to records
  • Bookmarks - Links to external URLs attached to records
  • Snippets - Code snippets and configuration files attached to records

Key Characteristics:

  • Single class for multiple content types (Type property determines behavior)
  • Links to parent records via ReferenceId property
  • Support for file uploads via Load() static method
  • Automatic file storage handling via FileContents property
  • Visible in record's Notes & Attachments section

NoteAndAttachment vs Document:

  • NoteAndAttachment = Content attached to specific records (via ReferenceId)
  • Document = Content organized in Document Library folders (via FolderId)
  • Different use cases and visibility in the platform

NoteAndAttachment Types

The Type property determines the content type:

Type ValueType NameDescriptionUse Case
0NoteText-based noteComments, descriptions, meeting notes
1File AttachmentUploaded filePDFs, images, documents attached to records
2BookmarkExternal URL linkLinks to external resources for a record
3SnippetCode snippet or configuration fileJavaScript, C#, CSS, JSON, XML, SQL code attached to records

NoteAndAttachment Properties Reference

Core Properties

PropertyTypeRequiredDescription
IdstringAutoSystem-generated unique identifier (read-only)
NamestringYesDisplay name for the note/attachment/bookmark/snippet
TypeintYesContent type: 0 = Note, 1 = File, 2 = Bookmark, 3 = Snippet
ReferenceIdstringYesID of the parent record this content is attached to
BodystringVariesContent based on Type (see below)

Body Property Usage by Type

TypeBody ContainsExample
Note (0)Note text content"Meeting notes from client call..."
File (1)File description"Q4 Financial Report"
Bookmark (2)URL"https://example.com/resource"
Snippet (3)Code or configuration text"function calculate() { return x + y; }"

File-Specific Properties

PropertyTypeRequiredDescription
FileContentsstringFor filesBase64-encoded file content (automatically handled by Load())
ContentTypestringFor filesMIME type (e.g., "application/pdf", "image/png")

System Fields

PropertyTypeRequiredDescription
CreatedOnDateTimeAutoRecord creation timestamp (read-only)
CreatedByIdstringAutoUser ID who created the record (read-only)
ModifiedOnDateTimeAutoLast modification timestamp (read-only)
ModifiedByIdstringAutoUser ID who last modified (read-only)

Static Methods Reference

MethodReturn TypeDescription
Load(HttpPostedFile file)NoteAndAttachmentCreates NoteAndAttachment from uploaded file with auto-populated properties

NoteAndAttachment.Load() Method

Creates a NoteAndAttachment object from an uploaded file with properties automatically populated.

Signature:

static NoteAndAttachment Load(HttpPostedFile file)

Parameters:

  • file (HttpPostedFile, required) - The uploaded file from aspx:FieldFileUpload

Returns:

  • NoteAndAttachment object with populated properties, or null if file is empty

Auto-Populated Properties:

  • Name - Original filename
  • Type - Automatically set to 1 (File Attachment)
  • ContentType - MIME type from uploaded file
  • FileContents - Base64-encoded file content

Properties You Must Set:

  • ReferenceId - ID of the parent record

Property Details

Type

Determines the content type of the NoteAndAttachment record.

Type: int
Required: Yes

Valid Values:

  • 0 - Note (text content)
  • 1 - File Attachment
  • 2 - Bookmark (URL)
  • 3 - Snippet (code or configuration file)

Description: The Type property controls how the platform interprets and displays the NoteAndAttachment record. Different types use the Body and other properties differently.


Body

Multi-purpose content field used differently based on Type.

Type: string
Required: Yes (except file description is optional)

Usage by Type:

For Notes (Type = 0):

  • Contains the note text content
  • Supports plain text and rich text
  • No length limit (within reasonable database constraints)

For File Attachments (Type = 1):

  • Contains optional file description or comments
  • Not the file content itself (use FileContents for file data)
  • Descriptive text about the file

For Bookmarks (Type = 2):

  • Contains the URL string
  • Must be valid URL format (http:// or https://)
  • Max 2000 characters

For Snippets (Type = 3):

  • Contains the code or configuration file content
  • Plain text format
  • Common snippet types: JavaScript (.js), C# (.cs), CSS (.css), JSON (.json), XML (.xml), SQL (.sql), HTML (.html)
  • Used for storing code samples, configuration files, and script fragments

ReferenceId

ID of the parent record to which this content is attached.

Type: string
Required: Yes

Description: Links the NoteAndAttachment to a specific parent record. Content appears in the Notes & Attachments section of that record's detail page.

Usage:

  • Set to any valid record ID in the system
  • Commonly used with: Account, Contact, Opportunity, Case, custom entities
  • Must be valid existing record ID
  • Cannot be null or empty

FileContents

Base64-encoded file content for file attachments.

Type: string
Required: Only when Type = 1 (file attachments)

Description: Contains the actual file data encoded as a Base64 string. When a file is uploaded, its bytes are converted to Base64 and stored in this property.

Automatic Population:

  • Automatically set when using Load() method
  • Handles encoding internally
  • No manual encoding needed when using Load()

Important Notes:

  • Only relevant for Type = 1 (file attachments)
  • Ignored for Types 0, 2, 3
  • Maximum file size subject to platform limits

ContentType

MIME type of the attached file.

Type: string
Required: Recommended for Type = 1

Description: Specifies the MIME type of the file attachment. Used by browsers to determine how to handle file downloads.

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

Automatic Population:

  • Automatically set when using Load() method
  • Extracted from uploaded file's content type

Snippet Usage (Type = 3)

Snippets are code files and configuration content attached to records for development, configuration, and technical documentation purposes.

Properties for Snippets:

  • Name - Snippet filename or identifier (e.g., "validation.js", "config.json")
  • Body - Code or configuration content
  • Type - Set to 3
  • ReferenceId - Parent record ID

Common Snippet File Types:

  • JavaScript (.js) - JavaScript code snippets and functions
  • C# (.cs) - C# code samples and class definitions
  • CSS (.css) - Stylesheet snippets and style definitions
  • JSON (.json) - Configuration files and data structures
  • XML (.xml) - XML configuration and data files
  • SQL (.sql) - SQL queries and database scripts
  • HTML (.html) - HTML markup snippets
  • TypeScript (.ts) - TypeScript code snippets
  • Python (.py) - Python code samples
  • YAML (.yaml/.yml) - YAML configuration files

Use Cases:

  • Code samples for integration documentation
  • Configuration file templates
  • SQL query libraries attached to projects
  • JavaScript functions for custom implementations
  • CSS style overrides for customizations
  • API request/response examples in JSON
  • Script fragments for automation

Snippet vs Document Snippet:

FeatureNoteAndAttachment SnippetDocument Snippet
Type3 (int)"Snippet" (string)
StorageAttached to records (ReferenceId)Document Library folders (FolderId)
Extension fieldNot usedRequired (js, css, html, etc.)
ContentType fieldNot used"Snippet"
UniqueName fieldNot usedRequired
Use CaseCode/config attached to specific recordsCode/config organized in Document Library
Body persistencePersisted in databaseTransient (stored in cloud storage)

Related Topics