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 SDKInclude 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 SDKCall 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 eventsThe following core events are available in all widget types.
Event | Description |
---|---|
app.loaded | As soon as communication with the Facilio is established, the SDK triggers an app.loaded event. |
app.destroyed | Fires when the app becomes inactive. |
Example
app.on("app.loaded", (data) => { console.log(data);});
app.on("app.destroyed", () => { console.log("app destroyed");});
#
Global functionsThe following core functions are available in all widget types.
Method | Description |
---|---|
getWidget | Get current connected app widget object. |
getContext | Get current record object. |
getCurrentUser | Get current user object. |
getCurrentOrg | Get 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 functionsMethods for listening live events, accessing the Facilio interface, getting or setting variables, invoking api, and more.