executeConnection()
Last updated 18/09/2024
The following code demonstrates how to use
executeConnection()
with a pre-configured connection endpoint.
Example One
Reading a list from a pre-configured connection
let results = five.executeConnection('ODataRW', 'LIST');
if (results.isOk()) {
five.log('Record Count : ' + results.recordCount())
}
Example Two
Creating a new record using an OData configured connection
const newRecord = {
record: {
"FirstName":"John",
"Gender":"Male",
"LastName":"Citizen",
"UserName":"jcitizen"
}
};
results = five.executeConnection('ODataRW', 'CREATE', newRecord);
if (results.isOk()) {
five.log('Record Created')
}
Example Three
Retrieving a record using an OData configured connection
results = five.executeConnection('ODataRW', 'READ', {key: 'jcitizen'});
if (results.isOk() && results.recordCount() === 1) {
five.log('Record Retrieved : ' + results.records[0].FirstName);
}
Example Four
Updating an existing OData record
const updateRecord = {
key: 'jcitizen',
record: {
"FirstName":"John",
"Gender":"Male",
"LastName":"Citizen",
"UserName":"jcitizen2"
}
};
results = five.executeConnection('ODataRW', 'UPDATE', updateRecord);
if (results.isOk()) {
five.log('Record Updated')
}