Is there anyway to see previous / new values in an update action?

I am updating a value from a UI but would like to check the old value vs new value in the update.js action, is this possible please? I can do this in a global action before firing the update but would be cool if there was some native functionality. Thanks Gadget assistant suggests code that doesn't appear to respond with methods that don't appear to exist.
// Check if a specific field has changed
if (record.changed("fieldName")) {
// The field has changed
console.log("Field has changed");

// You can access the previous value using record.getOld()
const oldValue = record.getOld("fieldName");

// You can access the new value directly from the record
const newValue = record.fieldName;

console.log(`Changed from ${oldValue} to ${newValue}`);
}
// Check if a specific field has changed
if (record.changed("fieldName")) {
// The field has changed
console.log("Field has changed");

// You can access the previous value using record.getOld()
const oldValue = record.getOld("fieldName");

// You can access the new value directly from the record
const newValue = record.fieldName;

console.log(`Changed from ${oldValue} to ${newValue}`);
}
2 Replies
OllieEvans
OllieEvansOP6mo ago
Ah excellent, I thought the Assistant had done a made one. Thanks, ill take a look

Did you find this page helpful?