Read ( R ) the Account Record
Now back to the app! We click on the Edit button next to the found record.
In the right pane a new Lightning form named “Update Account Record” appears. The form is filled with the values of the Acme Associates, Inc. records, and the form is editable.
As you may have guessed, the form “Update Account Records” is another LWC, named
editAccount
.
The LWCs createAccount
and editOrDeleteAccount
are
children of the LWC homepage, but editAccount
is a sibling. Because of
this we use the pubSub module which enables sister LWCs on the same app page to
communicate.
For more information about pubSub, see the Lightning Web Components Dev Guide, Communicate Between Components (https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.events_pubsub)
The controller for our editAccount
LWC uses
updateRecord()
from the lightning/uiRecordApi
. The
controller also uses the functions getRecord()
and
getFieldValue()
. The names of these functions should be
self-explanatory, but we’ll still briefly discuss them.