Live Event
You can use the LiveEvent to enable an app to trigger certain actions whenever event received from Facilio Script. This will be useful for notifying custom messages on Facilio interface (eg: Critical alarms).
#
subscribeUserEventapp.liveevent.subscribeUserEvent(topic)
- Is used to listen to custom user level events which are sent from Facilio script.
- Sending event from Facilio Script
- Receiving event from Connected App
content = {};content.label = "some data";content.value = 1000; message = {};message.to = <to user id>;message.topic = "new_alarm_event";message.content = content;log message; new NameSpace("wms").sendMessageToUser(message);
async function listenUserEvents() { let subscribedToken = await app.liveevent.subscribeUserEvent('new_alarm_event'); app.on(subscribedToken, (data) => { console.log('live user data: ', data); });
// (optional) later if you want to unsubscribe the topic, you can do it using the token app.liveevent.unsubscribe(subscribedToken);}listenUserEvents();
#
subscribeOrgEventapp.liveevent.subscribeOrgEvent(topic)
- Is used to listen to custom org level events which are sent from Facilio script.
- Sending event from Facilio Script
- Receiving event from Connected App
content = {};content.label = "some data";content.value = 1000; message = {};message.orgId = currentOrg.id;message.topic = "new_alarm_event";message.content = content;log message; new NameSpace("wms").sendMessageToOrg(message);
async function listenOrgEvents() { let subscribedToken = await app.liveevent.subscribeOrgEvent('new_alarm_event');
app.on(subscribedToken, (data) => { console.log('live org data: ', data); });
// (optional) later if you want to unsubscribe the topic, you can do it using the token app.liveevent.unsubscribe(subscribedToken);}listenOrgEvents();