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
Field Type Required Description
recordId number No ID of the record where the file will be inserted.
restrictedArea Object No Restricted area info.
restrictedArea.code string No Restricted area code.
restrictedArea.name string No Restricted area name.
relatedRecords Array No Related records.
metadata Object No Document metadata.
metadata.documentId string No Document ID.
metadata.documentType string No Document type.
metadata.description string No Description.
metadata.documentDate string No Document date.
metadata.documentLocation string No Document location.
metadata.companyId string No Company ID.
metadata.companyName string No Company name.
metadata.companyRegistrationNumber string No Company registration number.
metadata.matterId string No Matter ID.
metadata.matterType string No Matter type.
metadata.matterTitle string No Matter title.
metadata.matterLocation string No Matter location.
metadata.matterNote string No Matter note.
metadata.matterProcessNumber string No Process number.
metadata.matterProcessParty string No Process party.
options Object No Additional creation options.
options.removeOlderVersions boolean No Remove older versions.
options.createShareLink boolean No Create share link.
options.doNotCreateStructure boolean No Do not auto-create structure.
options.createNewRecord boolean No Create a new record.
options.ocr boolean No Run OCR.
options.listFilesRequest Object Yes File listing parameters:
Field Type Required Description
recordId number No Record ID for listing.
hierarchyLevel string Yes Hierarchy level:  rootcompany, matter, document.
options.sections Object No Sections parameters:
Field Type Required Description
navbar boolean No Show/Hide navbar menu.

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:
Field Type Required Description
q string No The query's string.
recordType<br> string No Specify a type of record that records will required to be in order to be hits.

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.