API
API functions used to manipulate data on the Facilio modules. All these actions are based on current user permissions.
#
createRecordapp.api.createRecord(moduleName, options)
- Is used to create records on a particular module.
Params
Param | Description |
---|---|
moduleName | The moduleName where the record should be created |
options | Record data as json. |
Example
const workorderData = { subject: ‘sample workorder from connected app’, siteId: 123, description: ‘workorder content’};
app.api.createRecord(‘workorder’, {data: workorderData});
#
updateRecordapp.api.updateRecord(moduleName, options)
- Is used to update records on a particular module by using the record id.
Params
Param | Description |
---|---|
moduleName | The moduleName where the record should be updated |
options | Record 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});
#
fetchRecordapp.api.fetchRecord(moduleName, options)
- Is used to fetch record on a particular module by using the record id.
Params
Param | Description |
---|---|
moduleName | The moduleName where the record should be fetched. |
options | Fetch record options. |
Example
const recordId = 123;
app.api.fetchRecord(‘workorder’, {id: recordId}) .then((response) => { console.log(response); })
#
deleteRecordapp.api.deleteRecord(moduleName, options)
- Is used to delete record on a particular module by using the record id.
Params
Param | Description |
---|---|
moduleName | The moduleName where the record should be deleted. |
options | Delete record options. |
Example
const recordId = 123;
app.api.deleteRecord(‘workorder’, {id: recordId});
#
fetchAllapp.api.fetchAll(moduleName, options)
- Is used to fetch a list of records on a particular module.
Params
Param | Description |
---|---|
moduleName | The moduleName where the record should be fetched |
options | Fetch 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); })