McFile Widget
An easy way to integrate McFile is through the Widget, an embedded component that enables creating, searching, and retrieving documents directly inside the McFile interface. The Widget is dynamically processed in JavaScript and hosted on our servers, allowing automatic updates without requiring any action from you.
McFile Widget • See the Widget in action on:
https://<domain>.mcfile.com/mcfile/widget
domain = McFile account subdomain. Login is required.
Getting Started
1) Include the script
Insert the script below into your page:
<script src="https://cdn.mcfile.com/widget/McFileWidgetListing.js"></script>
2) Configure and open the Widget
Basic initialization example:
const widget = McFileWidgetListing.configure({
url: '...',
domain: '...',
onReady: function () {},
createFile: function (createFileResponse) {},
error: function(code, message) {},
});
widget.open({
width: '...',
height: '...',
containerId: '...',
createFileRequest: {},
listFilesRequest: {},
});
Widget API Reference
configure
Signature
McFileWidgetListing.configure(options)
Configures the Widget using the provided options.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
options |
Object | Yes | Configuration object. |
options.domain |
string | Conditional | McFile account subdomain. Required if url is not provided. |
options.url |
string | Conditional | McFile access URL. Required if domain is not provided. |
options.onReady |
function | No | Callback triggered when widget is loaded and ready. |
options.createFile |
function | No | Callback triggered when a file is created. |
options.error |
function | No | Callback triggered when an error occurs. |
open
Signature
widget.open(options)
Opens the Widget using the provided options.
Parameters
| Name | Type | Required | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Yes | Object containing Widget opening options. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options.width |
string | No | Widget width. Default: '100%' |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options.height |
string | No | Widget height. Default: '100%' |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options.containerId |
string | No | ID of the HTML element where the Widget will be created. Default: 'mcfileWidget' |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options.createFileRequest |
Object | No | File creation parameters. More info: API docs
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options.listFilesRequest |
Object | Yes | File listing parameters:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options.sections |
Object | No | Sections parameters:
|
search
Signature
widget.search(searchRequest)
Perform a search using the provided search parameters. More info: API docs
Parameters
| Name | Type | Required | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
searchRequest |
Object | Yes | Search request object. | ||||||||||||
searchRequest.searchType |
string | Yes | Either record or file |
||||||||||||
searchRequest.query |
Object | Yes | Query parameters:
|
navigate
Signature
widget.navigate(navigateRequest)
Navigates to a folder according to the provided navigation parameters.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
navigateRequest |
Object | Yes | Navigate request object. |
navigateRequest.companyId |
number | Conditional | ID of the company record (recordId). If provided, the widget will navigate to the company folder. |
navigateRequest.recordId |
number | Conditional | ID of the record. If provided, the widget will navigate to the record folder. |
navigateRequest.fileId |
number | Conditional | ID of the file. If provided, the widget will navigate to the folder where the file is located. |
reload
Signature
widget.reload(configureOpts, openOpts)
Reloads the widget according to the provided reload parameters.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
configureOpts |
Object | Yes | Configuration object. (See "configure" signature) |
openOpts |
Object | Yes | Object containing Widget opening options. (See "open" signature) |
Events (Callbacks)
createFile
Signature
createFile(createFileResponse)
Triggered when a file is created. More info: API docs
Response
| Field | Type | Description |
|---|---|---|
recordId |
number | ID of the record where the file was inserted. |
createdBy |
Object | Creator user: userId, name. |
createdDate |
string | Creation date. |
fileId |
string | File ID. |
links |
Object | Links: viewer, download, thumb, self. |
modifiedBy |
Object | Last modifier: userId, name. |
modifiedDate |
string | Last modified date. |
name |
string | File name. |
size |
number | File size. |
status |
string | File status. |
version |
number | File version. |
error
Signature
error(code, message)
Triggered when an integration error occurs.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
code |
string | number | Yes | Error identifier. |
message |
string | Yes | Error details. |
Full Example
Scenario: Listing and creating files for the Lorem ipsum matter at Xpto Inc.
<script>
let recordId;
const widget = McFileWidgetListing.configure({
domain: 'xpto',
createFile: function (createFileResponse) {
alert("File created");
console.log(createFileResponse);
recordId = createFileResponse.recordId;
}
});
widget.open({
containerId: 'mcfile-container',
createFileRequest: {
recordId: recordId || 0,
metadata : {
documentType: "Agreement",
description: "Test agreement",
companyName: "Xpto Inc.",
matterType: "Litigation",
matterTitle: "Lorem ipsum"
},
options : {
removeOlderVersions: false,
createShareLink: false,
doNotCreateStructure: true,
createNewRecord: true,
ocr: false
}
},
listFilesRequest: {
recordId: 119512686,
hierarchyLevel: "matter"
}
});
</script>
Note: Always provide the recordId when possible.