Requirement
We want a workspace page to update a record with one or more values.
Solution
There are two main ways to update a record in UI Builder and both involve using the Update Record
data resource.
Using the UI
- Click on "+" to open a new data resource
- Select the OOB
Update Record
data resource - Click add and give it an id, for instance
update_record
- In an event mapping (for instance on a button click) add an event handler and select the
update_record
data resource - Configure the
Table
andRecord
(sys_id
) - Click on
Edit field values
to specify which fields to update - (This is a bit counterintuitive) Add the fields you want to change as
is
filters. If you want to change 2 fields, you need to add them as 2is
filters. - Click Submit
Using scripting
(Steps 1-4 are the same as above)
- Click on "+" to open a new data resource
- Select the OOB
Update Record
data resource - Click add and give it an id, for instance
update_record
- In an event mapping (for instance on a button click) add an event handler and select the
update_record
data resource - In the event mapping configuration select
Script
mode - In the
Script
section add something like the following:function handler({api,event, helpers, imports}) { let fields = "value=" + api.state.date_format; // Note query syntax api.data.update_record_1.execute({ table: "sys_properties", recordId : api.data.getsystemproperty.output.sysId, templateFields: fields, useSetDisplayValue: false }); }