Object Value Methods
Object fields should be assigned with plain JSON-compatible objects. Guard unknown input before reading properties.
Assignment
const location = {
address: String(payload.input.address || '').trim(),
city: String(payload.input.city || '').trim(),
};
await context.form.update({
recordId: 'record-id',
data: {
delivery_location: location,
},
});
Accepted input examples:
| Input | Normalized Value |
|---|---|
{ address: '...', city: 'Shanghai' } | same object shape |
| JSON text | parse before writing |
null | clear the field when allowed |
Common Methods
| Method | Use |
|---|---|
Object.keys(value) | Get property names |
Object.values(value) | Get property values |
Object.entries(value) | Iterate property pairs |
{ ...value, key: next } | Create an updated object |
value?.property | Read optional nested properties |
const raw = record.data.delivery_location;
const location =
raw && typeof raw === 'object' && !Array.isArray(raw)
? (raw as Record<string, unknown>)
: {};
Object.keys(value)
Get property names.
const hasAddress = Object.keys(location).includes('address');
Object.values(value)
Get property values.
const filledParts = Object.values(location).filter((value) =>
String(value || '').trim()
);
Object.entries(value)
Iterate property pairs.
const normalizedLocation = Object.fromEntries(
Object.entries(location).map(([key, value]) => [
key,
typeof value === 'string' ? value.trim() : value,
])
);
{ ...value, key: next }
Create an updated object without mutating the original value.
const city = String(location.city || '');
const normalized = {
...location,
city: city.trim(),
};
value?.property
Read optional nested properties.
const coordinates =
location.coordinates &&
typeof location.coordinates === 'object' &&
!Array.isArray(location.coordinates)
? (location.coordinates as Record<string, unknown>)
: null;
const longitude = Number(coordinates?.lng);