Skip to main content

Installation

The Facilio Apps SDK lets your app in the iframe communicate with the Facilio product. You can use the sdk in your apps to listen for events, invoke facilio api or thridparty api.

Getting the SDK#

Include the SDK script tag in your file.

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

When you include the SDK on your html, you get access to the FacilioAppSDK object.

Initializing the SDK#

Call the init method to setup the SDK. And, it will return instance of FacilioAppSDK object.

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

Working with SDK#

Global events#

The following core events are available in all widget types.

EventDescription
app.loadedAs soon as communication with the Facilio is established, the SDK triggers an app.loaded event.
app.destroyedFires when the app becomes inactive.

Example

app.on("app.loaded", (data) => {  console.log(data);});
app.on("app.destroyed", () => {  console.log("app destroyed");});

Global functions#

The following core functions are available in all widget types.

MethodDescription
getWidgetGet current connected app widget object.
getContextGet current record object.
getCurrentUserGet current user object.
getCurrentOrgGet current organization object.

Example

let widget = app.getWidget();if (widget.widgetType === "SUMMARY_PAGE") {  // do this}
let currentRecord = app.getContext();console.log("Record Name: " + currentRecord.name);
let currentUser = app.getCurrentUser();console.log("Current User Email: " + currentUser.email);
let currentOrg = app.getCurrentOrg();console.log("Current Org Domain: " + currentOrg.domain);

Other functions#

Methods for listening live events, accessing the Facilio interface, getting or setting variables, invoking api, and more.