DocumentLibrary

DocumentLibrary allows users to manage files under the "Company Library" module in Maximizer CRM.

A DocumentLibrary entry is a reference to identify a binary (file) previously loaded and stored in Maximizer CRM. See below some considerations for DocumentLibrary object:

  • Currently we can create three types of entries using DocumentLibrary:

    • Document (binary file)\

    • Note (compound document file)\

    • Hyperlink\

  • Differently from regular Documents (that are always associated with a specific AbEntry or Opportunity or Case, for example), DocumentLibrary entries are general purpose information hierarchically organized in folders.\

  • Independently of what DocumentLibrary type of entry we are creating, the process depends on an extra step to upload the content as a "binary" file.

    • When creating a Note (Type = 4), the binary file must be in a Microsoft Compound Document File format (a.k.a. OLE Structured Storage). For more details about this format, please refer to [MS-CFB]: Compound File Binary File Format | Microsoft Learn.\

    • When creating a Document (Type = 8), the binary file is the actual binary representation of that file (whatever file type it is).\

    • When creating a Hyperlink (Type = 16), the binary file must contain the textual representation of that hyperlink. In other words, it should be a textfile containing the actual URL.\

  • To upload the binary file, a special endpoint has to be used. See examples in the HowTo's section for specific details.\

  • When binary files are loaded, they are stored in a swap area. When a DocumentLibrary entry is created using the BinaryDataId (a.k.a. AttachmentId) reference, the default behavior is for the temporary file to be deleted from the swap area. It won't be available for further usage.\

  • To override this behavior (and use the very same binary file for creating multiple DocumentLibrary entries), the option "BinaryFileCleanup" needs to be specified when creating the entry. See examples in the HowTo's section for specific details.

HowTo's

Entry Type = 4 (Note)

Create a DocumentLibrary Note in Maximizer (Step 1 - Upload Binary)

// POST https://api.maximizer.com/octopus/BinaryUpload
// Authorization: Bearer <token>

Example: Response

// Request →
// POST https://api.maximizer.com/octopus/BinaryUpload
// Authorization: Bearer <token>
// Response ←
// When POST to BinaryUpload endpoint, the body provided must be the actual binary file (in this case, it must be a textfile with the actual Note content).
// The binary file will be uploaded to a swap area and you are provided with a BinaryDataId identifier.
// You can use the BinaryDataId to reference this binary when creating the actual Document later on.
{
    "Code": 0,
    "BinaryData": {
        "Data": {
            "Size": 14493,
            "BinaryDataId": "429e276b-4e5f-44b0-ae37-064565eac287"
        }
    }
}

Create a DocumentLibrary Note in Maximizer (Step 2 - Create the actual entry)

// POST https://api.maximizer.com/octopus/Create
// Authorization: Bearer <token>
{
    "DocumentLibrary": {
        "Data": {
            "Key": null,
            "Name": "Test DocumentLibrary - Note",
            "Description": "This is a test for creating a Note entry",
            "Type": 4, // Note
            "BinaryDataId": "7cb1e05d-7841-4bd8-9f40-d2fe1cb7caae",
            "FolderKey": null // will be created in the root folder
        }
    }
}

Create a DocumentLibrary Note in Maximizer (Step 2b - Create the actual entry and keep binary)

// POST https://api.maximizer.com/octopus/Create
// Authorization: Bearer <token>
{
    "DocumentLibrary": {
        "Data": {
            "Key": null,
            "Name": "Test DocumentLibrary - Note",
            "Description": "This is a test for creating a Note entry",
            "Type": 4, // Note
            "BinaryDataId": "7cb1e05d-7841-4bd8-9f40-d2fe1cb7caae",
            "FolderKey": null // will be created in the root folder
        },
        "Options": {
            "BinaryFileCleanup": false // Use this option to keep the binary available for other DocumentLibrary entry creations
        }
    }
}

Download DocumentLibrary Note Binary

// GET https://api.maximizer.com/octopus/BinaryDownload/document-key-here
// Authorization: Bearer <token>

Entry Type = 8 (Document)

Create a DocumentLibrary Document in Maximizer (Step 1 - Upload Binary)

// POST https://api.maximizer.com/octopus/BinaryUpload
// Authorization: Bearer <token>

Example: Response

// Request →
// POST https://api.maximizer.com/octopus/BinaryUpload
// Authorization: Bearer <token>
// Response ←
// When POST to BinaryUpload endpoint, the body provided must be the actual binary file.
// The binary file will be uploaded to a swap area and you are provided with a BinaryDataId identifier.
// You can use the BinaryDataId to reference this binary when creating the actual Document later on.
{
    "Code": 0,
    "BinaryData": {
        "Data": {
            "Size": 14493,
            "BinaryDataId": "429e276b-4e5f-44b0-ae37-064565eac287"
        }
    }
}

Create a DocumentLibrary Document in Maximizer (Step 2 - Create the actual entry)

// POST https://api.maximizer.com/octopus/Create
// Authorization: Bearer <token>
{
    "DocumentLibrary": {
        "Data": {
            "Key": null,
            "Name": "Test DocumentLibrary Entry - Document",
            "Description": "This is a test for creating a Document entry",
            "Ext": "xlsx",
            "Type": 8, // Document
            "BinaryDataId": "42df48aa-aeaf-4d24-ad58-281c5e15668c",
            "FolderKey": null // will be created in the root folder
        }
    }
}

Create a DocumentLibrary Document in Maximizer (Step 2b - Create the actual entry and keep binary)

// POST https://api.maximizer.com/octopus/Create
// Authorization: Bearer <token>
{
    "DocumentLibrary": {
        "Data": {
            "Key": null,
            "Name": "Test DocumentLibrary Entry",
            "Description": "",
            "Ext": "xlsx",
            "Type": 8, // Document
            "BinaryDataId": "8fc30b91-807e-4fbb-bf0a-4e57a237256c",
            "FolderKey": null // will be created in the root folder
        },
        "Options": {
            "BinaryFileCleanup": false // Use this option to keep the binary available for other DocumentLibrary entry creations
        }
    }
}

Download DocumentLibrary Document Binary

// GET https://api.maximizer.com/octopus/BinaryDownload/document-key-here
// Authorization: Bearer <token>

Entry Type = 16 (Hyperlink)

Create a DocumentLibrary Hyperlink in Maximizer (Step 1 - Upload Binary)

// POST https://api.maximizer.com/octopus/BinaryUpload
// Authorization: Bearer <token>

Example: Response

// Request →
// POST https://api.maximizer.com/octopus/BinaryUpload
// Authorization: Bearer <token>
// Response ←
// When POST to BinaryUpload endpoint, the body provided must be the actual binary file (in this case, it must be a textfile with the actual Hyperlink URL).
// The binary file will be uploaded to a swap area and you are provided with a BinaryDataId identifier.
// You can use the BinaryDataId to reference this binary when creating the actual Document later on.
{
    "Code": 0,
    "BinaryData": {
        "Data": {
            "Size": 14493,
            "BinaryDataId": "429e276b-4e5f-44b0-ae37-064565eac287"
        }
    }
}

Create a DocumentLibrary Hyperlink in Maximizer (Step 2 - Create the actual entry)

// POST https://api.maximizer.com/octopus/Create
// Authorization: Bearer <token>
{
    "DocumentLibrary": {
        "Data": {
            "Key": null,
            "Name": "Test DocumentLibrary Entry - Hyperlink",
            "Description": "This is a test for creating a Hyperlink entry",
            "Type": 16, // Hyperlink
            "BinaryDataId": "aace2d2c-87dc-47b3-8ad3-d41587b8828e",
            "FolderKey": null // will be created in the root folder
        }
    }
}

Create a DocumentLibrary Hyperlink in Maximizer (Step 2b - Create the actual entry and keep binary)

// POST https://api.maximizer.com/octopus/Create
// Authorization: Bearer <token>
{
    "DocumentLibrary": {
        "Data": {
            "Key": null,
            "Name": "Test DocumentLibrary Entry - Hyperlink",
            "Description": "This is a test for creating a Hyperlink entry",
            "Type": 16, // Hyperlink
            "BinaryDataId": "aace2d2c-87dc-47b3-8ad3-d41587b8828e",
            "FolderKey": null // will be created in the root folder
        },
        "Options": {
            "BinaryFileCleanup": false // Use this option to keep the binary available for other DocumentLibrary entry creations
        }
    }
}

Download DocumentLibrary Hyperlink Binary

// GET https://api.maximizer.com/octopus/BinaryDownload/document-key-here
// Authorization: Bearer <token>

Metadata

Read DocumentLibrary metadata (simple)

// POST https://api.maximizer.com/octopus/Read
// Authorization: Bearer <token>
{
    "Schema": {
        "Scope": {
            "Fields": 1
        },
        "Criteria": {
            "SearchQuery": {
                "Key": {
                    "$TREE": "/DocumentLibrary"
                }
            }
        }
    },
    "Compatibility": {
        "SchemaObject": "1.0"
    }
}

Read DocumentLibrary metadata (more)

// POST https://api.maximizer.com/octopus/Read
// Authorization: Bearer <token>
{
    "Schema": {
        "Scope": {
            "Fields": {
                "Key": 1,
                "Alias": 1,
                "Type": 1,
                "Name": 1,
                "AppliesTo": 1,
                "Sortable": 1,
                "Queryable": 1,
                "Assignable": 1,
                "Mandatory": 1,
                "Attributes": 1,
                "HasOption": 1,
                "DisplayValue": 1
            }
        },
        "Criteria": {
            "SearchQuery": {
                "Key": {
                    "$TREE": "/DocumentLibrary"
                }
            }
        }
    },
    "Compatibility": {
        "SchemaObject": "1.0"
    }
}

FieldOptions

Read DocumentLibrary FieldOptions - Type

// POST https://api.maximizer.com/octopus/Read
// Authorization: Bearer <token>
{
    "DocumentLibrary": {
        "FieldOptions": {
            "Type": {
                "Key": 1,
                "DisplayValue": 1
            }
        }
    }
}

DocumentLibrary CRUD

Create - DocumentLibrary

// POST https://api.maximizer.com/octopus/Create
// Authorization: Bearer <token>
{
    "DocumentLibrary": {
        "Data": {
            "Key": null,
            "Name": "Test DocumentLibrary Entry", // Mandatory
            "Description": "",
            "Ext": ".xslx", // Mandatory for Type = 8 (Document)
            // Type could be one of the following:
            // 4 = Note, 
            // 8 = Document, 
            // 16 = Hyperlink
            // Please check "FieldOptions" folder for details on how to retrieve the options for this field
            "Type": 1, // Mandatory
            // At first, upload a binary file to Octopus and use the resulting BinaryDataId (a.k.a. AttachmentId) here. For more details on how to do that, please check "Document/HowTo's" for samples
            "BinaryDataId": "06f15cf2-42e5-4669-8473-e3af5ac229e7", // Mandatory
            // The folder must exist to be used here. For more details on how to create a DocumentLibrary folder, check the "HowTo's" section for the "Folder" object. This is an optional field and the document will be created in the root of DocumentLibrary if no specific folder is provided
            "FolderKey": "RG9jRm9sZGVyCTc3MjIzODUxOQ=="
        }
    }
}

Read - DocumentLibrary

// POST https://api.maximizer.com/octopus/Read
// Authorization: Bearer <token>
{
    "DocumentLibrary": {
        "Scope": {
            "Fields": {
                "Key": 1,
                "Name": 1,
                "Description": 1,
                "Ext": 1,
                "Type": 1,
                "Size": 1,
                "BinaryDataId": 1,
                "FolderKey": 1,
                "Creator": 1,
                "CreationDate": 1,
                "LastModifiedDate": 1,
                "DisplayValue": 1
            }
        },
        "Criteria": {
            "SearchQuery": {},
            "Top": 3
        }
    }
}

Update - DocumentLibrary

// POST https://api.maximizer.com/octopus/Update
// Authorization: Bearer <token>
// When updating DocumentLibrary, the following fields CANNOT be changed:
// - Type
// - Ext
// - BinaryDataId (a.k.a. AttachmentId)
{
    "DocumentLibrary": {
        "Data": {
            "Key": "RG9jdW1lbnRMaWJyYXJ5CTE1MjAxODA0NDM=", // Mandatory
            "Name": "Name Updated",
            "Description": "Test Document Updated",
            // In case you want to change the folder where the document is stored, provide the FolderKey where you want the document "moved" to (folder MUST exist). If you want to move the document to the root of the DocumentLibrary, simply use FolderKey: null
            "FolderKey": "RG9jRm9sZGVyCTc3MjIzODUxOQ=="
        }
    }
}

Delete - DocumentLibrary

// POST https://api.maximizer.com/octopus/Delete
// Authorization: Bearer <token>
{
    "DocumentLibrary": {
        "Data": {
            "Key": "RG9jdW1lbnRMaWJyYXJ5CTE1MjAxODA0NDM=" // Mandatory
        }
    }
}