How can I find if a custom field(Sobject, Custom Setting/Metadata) exist in org using apex? I might have its partial name or similar sub string.
-
What do you mean by a partial name or sub string? How are you intending to use that to identify a field?– David ReedCommented Nov 1, 2019 at 0:05
-
It looks like you are looking for a Dynamic Search, but... why do you want to have something like that? It is part of a requirement?– Carlos NaranjoCommented Nov 1, 2019 at 0:05
-
@David, If field name is "Total Price", Then I shall be able to find field if I input "Total" or "Price"@Carlos, this is not part of requirement but something helpful while working– Ishwar MeteCommented Nov 1, 2019 at 0:08
-
1a pure apex option would be to use the Schema.Describe methods and loop through all fields in the returned map, using regex matching– cropredyCommented Nov 1, 2019 at 0:44
1 Answer
Well, the best option, in my opinion, is to use Salesforce Inspector:
After it is installed, you can access the Salesforce Inspector by clicking on the silver blue background arrow on top right from inside a record and click on "Show all data"
Then you can use the search function:
On the Filter search start typing the name of the field.... and voila :) The only thing you need to make sure is that you are inside the object to access the fields of that particular object...