isCustom() method from Schema.DescribeFieldResult can be used to find whether the field custom or standard in Salesforce using Apex.
Blog Post:
https://www.infallibletechie.com/2023/09/how-to-find-all-custom-fields-in-an-salesforce-object.html
Show More Show Less View Video Transcript
0:06
hello everyone
0:08
in this video we are going to see how to
0:11
find all custom fields from an object in
0:14
Salesforce using Apex
0:17
if you have a requirement where you
0:19
wanted to find all the custom fields in
0:20
an object then you can make use of the
0:22
sample piece of code which we are going
0:24
to refer in this video
0:27
in schema.describe field result we have
0:31
is custom method which can be used to
0:34
find whether a field is a custom field
0:38
or a standard field in Salesforce
0:40
let's look at a look at the sample code
0:43
first I am using schema dot describe s
0:46
object result I am assigning a variable
0:49
to it where I am trying to describe the
0:53
object account account.s object dot s
0:56
get described so this will describe and
1:00
it will give get all the meta data
1:02
information about the account object
1:04
using
1:06
map map of string comma schema.s object
1:10
field
1:12
um I am declaring a variable and
1:13
assigning it to this map type and
1:18
in order to get the string command a
1:21
subject field I am using S object
1:24
describe result dot fields.getmap so in
1:28
this uh
1:29
described result I will have more
1:32
information but in that I wanted to get
1:34
only the fields dot getmap so that I
1:37
will have string comma schema.s object
1:42
I wanted to
1:43
iterate schema Dot
1:46
s object so what I have done is
1:50
am I trading map field list
1:55
which will have the map I don't want the
1:58
key I want only the values so I'm using
2:00
the values method from the map data type
2:02
I'm iterating each and every field
2:05
and using schema.describe field result I
2:08
am describing the field so that I will
2:10
get more information about the field
2:12
value and then in using the field result
2:14
is custom so this is custom method will
2:17
check whether the field is a custom
2:19
field or a standard field
2:21
if it is a custom field then it will go
2:25
inside this if block and then it will
2:27
display what is the field label and what
2:29
is the field in a let's execute this
2:34
so enable debug only so I have all these
2:37
fields
2:38
in an in my account object which are
2:42
custom
2:49
please check the video description in
2:51
the video description I have shared my
2:53
blog post from the blog post you should
2:55
be able to get the sample code which we
2:57
referenced in this video
3:07
I hope it was helpful
3:16
thank you for watching
#Internet Software
