Wednesday, July 5, 2023

FieldDefinition - How to get list of all fields present in any Object using Tooling API in Salesforce

We can utilize Tooling API to get information of all fields present in a object. You can put different filters like to get all fields or specific fields like auto number fields, ExternalID fields etc.

Below is apex class which contains method to get all fields. Remember that callout uses Named Credential in order to do handshake with SFDC org.

This method contains 3 parameters:

  • selOrgNCName : Name of Named Credential created to connect to SFDC org
  • objAPIName : Specify the object API name in order to get list of all fields
  • namespacePrefix : Specify namespacePrefix if you want to retrieve fields related to any installed packages. If you want to get list of fields created in SFDC org, then specify blank or NULL.
  • I have added filter not to return auto number fields. If you want to get those fields details then remove it from query string.
  • If you want to query only External Id fields then specify filter as DataType+Like+\'%25(External+ID)%25\'';

Hope this will help!!

1 comment:

  1. Please, everyone should tread carefully with all these crypto brokers and crypto mining managers on social networks. I was duped with a whooping sum $ 640,000 of my investment capital by a broker I met via #Telegram. They kept on assuring me of my investment success growth while requesting for extra funds before a withdrawal request could be accepted and processed to access my investment, at the end of all my constant deposit, I lost all my money. All efforts trying to get them to return all I had invested with them was futile because they kept asking me for more money. I found myself in a very confusing state till recently when I was introduced to this group of Ethical Hackers. I wrote an email on ( cybergenie(@)cyberservices .co m) to them detailing my experience with that crypto broker, and they replied to me to provide proof of my investment with the said broker which I did, Lo and behold, before the end of the day, I got a notification from Trust Wallet of an incoming deposit, all that I lost was retrieved successfully..