Display Custom Metadata Type in Salesforce Lightning Web Component without Apex
289 views
Mar 10, 2025
The GraphQL wire adapter can be used to fetch/retrieve and display Custom Metadata Type records in Salesforce Lightning Web Component without using Apex. Blog Post: https://www.infallibletechie.com/2025/03/display-custom-metadata-type-in-salesforce-lightning-web-component-without-apex.html
View Video Transcript
0:07
hello everyone in this video we are
0:09
going to see how to
0:12
display or
0:14
fetch custom metadata type records from
0:19
Salesforce in lightning web component
0:22
without using
0:24
Apex we can make use of Salesforce Apex
0:28
to fetch custom metadata type records
0:32
using S soql and then we can use it in
0:36
our lightning web component we can use
0:39
wire framework to invoke the Apex class
0:41
method or we can imperatively call the
0:45
Apex class and its
0:47
method but if you have a requirement
0:51
where you wanted to achieve the same
0:53
functionality without using
0:56
Uh custom Apex then you can make use of
1:00
graph ql in Salesforce lightning web
1:04
component I created a sample custom
1:07
metadata type I created two custom
1:10
Fields one is for label and the other
1:13
one is for
1:15
Value if you wanted to make use of the
1:18
standard label instead of a custom field
1:22
then you can make use of master label
1:25
API name you need not create this label
1:28
field since it is a demo I have created
1:32
two
1:33
Fields label and
1:35
value I'm going to
1:38
fetch these uh custom metadata type
1:42
records from this custom metadata type
1:45
and display it as a drop- down box in
1:49
lightning web
1:51
component so this is my lightning web
1:54
component where I can see test one test
1:57
two test three all these values are
2:00
coming from this custom metadata
2:03
types let's
2:06
create few
2:17
more I'm going to create one more
2:41
I'm refreshing the lightning web
2:43
component so I'm able to see the custom
2:46
metadata type records in my lightning
2:49
web component in order to display this
2:53
lightning uh combo box with custom
2:56
metadata type records I haven't used a
3:00
in my lightning web
3:05
component so this is the custom meta
3:07
data type which we saw it uh in in the
3:11
Salesforce or and this is the lightning
3:13
web component HTML I am making use of
3:16
options to display the values whenever
3:19
they change it it will call this handle
3:21
change method Whenever there is a value
3:24
whenever they select something it will
3:26
display the selected value
3:29
I'm I'm making use
3:31
of
3:34
lightning SL UI graphql API and from
3:38
that I'm making use of these two
3:41
methods using wire framework I'm
3:44
invoking the graph
3:46
ql I'm going to query the sample
3:50
metadata
3:51
type and I need two field values one is
3:57
label and the other one is
4:00
value you can also make use of the
4:03
standard field for label whenever you
4:07
use a standard field make sure you are
4:09
using the API name not the label so it
4:12
should be master
4:14
label so once it get all the
4:19
values using options
4:23
variable I am iterating all the
4:26
records for label I'm using the label
4:29
value for the value I am making use of
4:32
Valore c.
4:34
value whenever they change it I'm
4:37
updating the value
4:40
variable to the selected
4:43
value so without using Apex with the
4:47
help of graph ql I was able to fetch the
4:50
custom metadata type
4:52
records and display it in my Salesforce
4:55
lightning web component
5:02
please check the video description in
5:04
the video description I have given my
5:06
blog post from the blog post you should
5:09
be able to get this sample lightning web
5:11
component code for your
5:24
reference I hope it was helpful
5:34
thank you for watching
#Internet Software
#Other