4. Update Record
context.sdk.entities.update({ params, json })
async· returns{ success, id, message }
Updates an existing record. Only the fields included in json are changed.
Prop
Type
context.component.updateByName("btnApproveRequest", "loading", true);
try {
const result = await context.sdk.entities.update({
params: { entitySlug: "timeoff", recordId: context.router.id },
json: { Status: 2 }
});
if (!result.success) throw new Error(result.message || "Update failed");
context.toast.success("Request approved.");
} catch (error) {
context.toast.error(error.message);
} finally {
context.component.updateByName("btnApproveRequest", "loading", false);
}Returned value
{
"success": true,
"id": 88,
"message": "Record updated successfully"
}ModifyDate and ModifyUser are updated by the platform. Pass lookup foreign keys as numbers (Status: 2), not as { ID: 2, Name: "Approved" }.
The UI refreshes on its own after a successful update. You do not need context.mutate.
Updating the row that was clicked
On a table action button, the row is context.event, not context.router.id:
await context.sdk.entities.update({
params: { entitySlug: "printjobs", recordId: context.event.ID },
json: { PrintStatusID: 14 }
});
context.toast.success("Print job cancelled.");