Skip to main content

Installation

The Facilio Apps SDK lets your app communicate with the Facilio platform from inside an iframe (web) or webview (mobile). Use it to listen for events, read and write module data, invoke APIs, and control the Facilio UI.

Getting the SDK#

Include the SDK script tag in your HTML file. There is no npm package — the SDK is loaded via CDN.

ChannelURLWhen to use
Latesthttps://static.facilio.com/apps-sdk/latest/facilio_apps_sdk.min.jsStandard for all customers
Betahttps://static.facilio.com/apps-sdk/beta/facilio_apps_sdk.min.jsRequired for Revive customers and for mobile widget support
Use beta for new development

For any new connected app development, use the beta SDK. It includes the latest platform support and is stable for production use.

Standard (latest)

<script type="text/javascript"  src="https://static.facilio.com/apps-sdk/latest/facilio_apps_sdk.min.js"></script>

Beta — recommended for Revive customers and mobile

<script type="text/javascript"  src="https://static.facilio.com/apps-sdk/beta/facilio_apps_sdk.min.js"></script>
tip

If you are a Revive customer or your widget needs to work on mobile, use the beta SDK. It is stable and includes the latest platform support for Revive and mobile rendering.

Initializing the SDK#

Call FacilioAppSDK.init() or FacilioAppSDK.initSync() to set up the SDK. Both return the SDK instance. No behavioral difference — use init() for callback style or initSync() for async/await.

// Callback modevar app = FacilioAppSDK.init((data) => {  console.log('Facilio SDK loaded successfully!', data);});
// Async modevar app = await FacilioAppSDK.initSync();console.log('Facilio SDK loaded successfully!', app.getContext());

In a Vue.js app, initialize in the created() lifecycle hook and store the instance on window:

created() {  window.facilioApp = FacilioAppSDK.init();  window.facilioApp.on('app.loaded', async (data) => {    await this.init();  });}

Events#

The following events are available in all widget types. Use on(name, handler) to subscribe, off(name, handler) to unsubscribe, and has(name, handler) to check registration — see Methods.

EventDescription
app.loadedFires when communication with Facilio is established. Always wait for this before making API calls.
app.destroyedFires when the app becomes inactive. Use for cleanup.

app.loaded payload — The data argument contains { widget, context, exportMode, currentUser, currentOrg } — equivalent to getWidget(), getContext(), isExportMode(), getCurrentUser(), getCurrentOrg().

Example

window.facilioApp.on('app.loaded', (data) => {  // data.widget, data.context, data.exportMode, data.currentUser, data.currentOrg  console.log('SDK ready', data);});
window.facilioApp.on('app.destroyed', () => {  console.log('App destroyed — cleanup');});

Core methods#

The following methods are available in all widget types after app.loaded fires.

MethodReturnsDescription
getWidget()ObjectCurrent widget config (entityTypeEnum, widgetName, linkName, etc.) — see Methods
getContext()ObjectRecord, page context, or widget-specific data — see Methods
getCurrentUser()ObjectUser (id, name, email, orgId, timezone, role, etc.) — see Methods
getCurrentOrg()ObjectOrganization (id, name, domain, timezone, currency, etc.) — see Methods
isExportMode()booleanWhether app is in export mode (PDF/image) — see Methods
isMobile()booleanWhether app is running on mobile — see Methods

Example

let widget = window.facilioApp.getWidget();if (widget.entityTypeEnum === 'SUMMARY_PAGE') {  // summary tab logic}
let currentRecord = window.facilioApp.getContext();console.log('Record Name:', currentRecord.name);
let currentUser = window.facilioApp.getCurrentUser();console.log('Email:', currentUser.email);
let currentOrg = window.facilioApp.getCurrentOrg();console.log('Domain:', currentOrg.domain);

Other SDK methods#

  • Data API — Create, read, update, delete module records
  • Variables — Key-value storage for app configuration
  • Request — Call connector APIs, external APIs, and Facilio functions
  • Interface — Navigate, show notifications, trigger widget actions
  • Live Events — Real-time event subscriptions
  • Common Utilities — Image-to-base64 conversion