Show More Show Less
View Video Transcript
0:05
Hello everyone. In this video, we are
0:07
going to see how to detect a record
0:10
update in Salesforce lightning web
0:13
component.
0:15
In your Salesforce lightning web
0:17
component, if you are making use of
0:20
target as lightning double_record page
0:22
and the lightning web component is added
0:24
to your lightning record page.
0:28
If a record is updated either by inline
0:30
edit or by clicking the edit button and
0:34
saving the record.
0:37
Then with the help of get record from
0:39
lightning
0:42
record sorry from the lightning UI
0:44
record API module you will be able to
0:47
detect it. Get record wire method from
0:51
the lightning UI record API module makes
0:54
use of lightning data service.
0:57
Since it is making use of the lightning
1:00
data service. If a record is updated
1:02
then the get record wire method will be
1:08
reinvoked or re-triggered so that you
1:10
can write your logic inside that get
1:14
record wire method.
1:17
For a simple demo I created this
1:19
lightning web component where I'm
1:20
displaying account name, industry, phone
1:23
and website.
1:26
I'm making use of get record from
1:28
lightning lightning UI record API
1:31
module.
1:32
I'm passing the currently viewing
1:34
account uh record ID with the help of
1:37
record ID at API variable.
1:41
Since I'm making use of lightning and
1:43
double record page and the record ID
1:45
will be the currently viewing account
1:48
record ID. I am setting the layout types
1:51
as full modes I have set it to view
1:56
from the wire method once it uh is
1:59
triggered
2:01
I'm getting the account name phone
2:03
website and industry from it if there is
2:06
an error I'm using console error so that
2:09
in the console I will be able to find
2:11
out if there if if it ran into any error
2:14
or exception.
2:18
Now let's see a simple demo. So this is
2:21
my lightning web component.
2:24
It is displaying the industry as
2:26
construction and phone ending with
2:28
double2. I'm going to edit this account
2:31
record. I'm going to change it to
2:34
double3
2:35
and instead of construction I'm going to
2:38
give it as consulting. I'm not
2:40
refreshing the page. By just clicking
2:42
save, the lightning data service will
2:46
re-trigger the get record wire method
2:48
again.
2:50
So I'm able to see the changes in the
2:52
lightning web component.
2:56
So I was able to detect the the record
2:58
changes with the help of get record from
3:01
the lightning UI record API module.
3:08
So you can also make use of this get
3:11
record wire method from the lightning UI
3:13
record API so that you can detect the
3:16
record that is getting changed.
3:21
Even if I do an inline edit so here I'm
3:24
going to edit it and change it to
3:27
energy.
3:29
Instead of double3 let me put double7.
3:32
If I click save, you should see the
3:34
updated information here.
3:39
So even for inline edit, the Lightning
3:42
data service will make sure to
3:43
re-trigger or reinvoke the get record
3:46
wire method.
3:54
Please check the video description. In
3:56
the video description, I have shared my
3:57
blog post. From the blog post, you
3:59
should be able to get the sample
4:00
lightning web component
4:04
so that you can refer it for your
4:06
development purpose.
4:15
I hope it was helpful.
4:22
Thank you for watching.
#Internet Software
#Science
