addRecord()
Last updated 10/03/2026
Definition
addRecord() is a function on the Five object
that adds a record to the current internal form transactions.
Examples
Creating a customer with a related address
This code demonstrates creating a new customer and a related address, adding both to Five's internal form transaction, and saving them to the database. Unique keys are generated for the customer and address, the records are created and linked via
CustomerKey
, and then added using addRecord()
. Lastly, saveRecords()
saves both records together, with callbacks to show a success message or
alert on failure.
Add a customer record and an address record
const customerKey = five.uuid();
let customerData: any = {};
customerData["CustomerKey"] = customerKey;
customerData["Name"] = "Bob";
customerData["Surname"] = "James";
customerData["Sex"] = "m";
const customerRecord = five.createRecord(customerKey, customerData);
five.addRecord(CustomerAction.key(), customerRecord);
const addressKey = five.uuid();
let addressData: any = {};
addressData["AddressKey"] = addressKey;
addressData["CustomerKey"] = customerKey;
addressData["Unit"] = "203";
addressData["No"] = "16";
addressData["Street"] = "Ethel St";
addressData["Suburb"] = "Chermside";
addressData["Postcode"] = "4032";
const addressRecord = five.createRecord(addressKey, addressData);
five.addRecord(AddressAction.key(), addressRecord);
five.saveRecords(() => {
// new customer has been saved
five.showMessage('New customer record created');
}, (err: any) => {
five.alert('Failed to create new customer record');
});
Add a customer record and an address record
const customerKey = five.uuid();
let customerData = {};
customerData["CustomerKey"] = customerKey;
customerData["Name"] = "Bob";
customerData["Surname"] = "James";
customerData["Sex"] = "m";
const customerRecord = five.createRecord(customerKey, customerData);
five.addRecord(CustomerAction.key(), customerRecord);
const addressKey = five.uuid();
let addressData = {};
addressData["AddressKey"] = addressKey;
addressData["CustomerKey"] = customerKey;
addressData["Unit"] = "203";
addressData["No"] = "16";
addressData["Street"] = "Ethel St";
addressData["Suburb"] = "Chermside";
addressData["Postcode"] = "4032";
const addressRecord = five.createRecord(addressKey, addressData);
five.addRecord(AddressAction.key(), addressRecord);
five.saveRecords(() => {
// new customer has been saved
five.showMessage('New customer record created');
}, (err) => {
five.alert('Failed to create new customer record');
});