Skip to main content

addRecord()

Last updated 8/07/2025

Example

The following code generates a unique ID for the customer and creates and populates a customer record. The same is done for an address record. Both records are saved and show a message on success or an alert if unsuccessful.

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');
});