Skip to main content

API

API functions used to manipulate data on the Facilio modules. All these actions are based on current user permissions.

createRecord#

app.api.createRecord(moduleName, options) - Is used to create records on a particular module.


Params

ParamDescription
moduleNameThe moduleName where the record should be created
optionsRecord data as json.

Example

const workorderData = {  subject: ‘sample workorder from connected app’,  siteId: 123,  description: ‘workorder content’};
app.api.createRecord(‘workorder’, {data: workorderData});

updateRecord#

app.api.updateRecord(moduleName, options) - Is used to update records on a particular module by using the record id.


Params

ParamDescription
moduleNameThe moduleName where the record should be updated
optionsRecord data as json.

Example

const recordId = 123;const workorderData = {  subject: ‘sample workorder from connected app’,  siteId: 123,  description: ‘workorder content’};
app.api.updateRecord(‘workorder’, {id: recordId, data: workorderData});

fetchRecord#

app.api.fetchRecord(moduleName, options) - Is used to fetch record on a particular module by using the record id.


Params

ParamDescription
moduleNameThe moduleName where the record should be fetched.
optionsFetch record options.

Example

const recordId = 123;
app.api.fetchRecord(‘workorder’, {id: recordId})  .then((response) => {     console.log(response);  })

deleteRecord#

app.api.deleteRecord(moduleName, options) - Is used to delete record on a particular module by using the record id.


Params

ParamDescription
moduleNameThe moduleName where the record should be deleted.
optionsDelete record options.

Example

const recordId = 123;
app.api.deleteRecord(‘workorder’, {id: recordId});

fetchAll#

app.api.fetchAll(moduleName, options) - Is used to fetch a list of records on a particular module.


Params

ParamDescription
moduleNameThe moduleName where the record should be fetched
optionsFetch records options.

Example


let params = {  viewName: 'all',  filters: JSON.stringify({     name: {       operator: ‘contains’,       value: [‘test’]     }  }),  page: 1,  perPage: 50,};

app.api.fetchAll(‘workorder’, params)  .then((response) => {     console.log(response);  })