0

I'm totally new to Salesforce, and was asked to provide a json result set with all objects, their associated fields (standard and custom), as well as all field attributes (name, id, type, etc.).

My interface for interacting with Salesforce is their small php example (Rest API): http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-php

I have found Apex (inside salesforce), and this looks like it might get me what I need. But, I do not know the Apex language.

Can anyone please point me in the correct direction? I found this post: How get all objects and their fields as Json

... but I'm lost. Do I run that from inside Apex?

Here is the kind of result set I am after:

{"animals":["bear", "cat", "dog"]}.... 

... but with all field attributes.

2

Well I believe you can do it with any language that supports HTTP calls by calling SFDC REST API OR via Apex directly OR you can use an appexchange package on AppExchange (I am not affiliated to this APP.)

I use JavaScript. SFDC has a rest API, however to access this you'll will require an access token which you can generate via Developer console easily(Execute System.debug(UserInfo.getSessionId()) in developer console's execute anonymous) or via OAuth Username-Password flow

Then use any language to issue a request to you instance

https://<instance>.salesforce.com/services/data/v26.0/sobjects

to get a list of all objects.

After you get the response containing all objects, you can issue http get calls one by one to

https://<instance>.salesforce.com/services/data/v34.0/sobjects/<OBJECTNAME>/describe

to get all the fields. Now you have all the data, you can do some JSON structuring to get the data in desired format.

| improve this answer | |
  • Thank YOU. I can get access token, I will check your links, and see how far I can make it. I'll brb to let you know how I do. Thank you so much. – josh Feb 16 '16 at 7:52
  • Holy freaking cow that got me close.. WOOHOO. But.. there are 528 objects in this application (I now know this thanks to your handiness above!!). But... can you think of a "one-off" query to get all fields with objects?? – josh Feb 16 '16 at 8:08
  • Oh my freaking gosh; you are AMAZING!! (All via php); I was able to loop the main results of all sobjects; then make a call for each sobject->label using your second query in a foreach loop; while building an array of key = sobject->label and value = the result set of the describe. Then, json_encode and BAM! Exactly what I need. I could kiss you!! Please create an answer so I can accept. How did you know to use the "/describe"? Where is THAT documentation?? Again, thank you. – josh Feb 16 '16 at 8:40
  • By the way... the final output resulted in a json string: string(1243088)... :) – josh Feb 16 '16 at 8:41
  • It's been a long, long night.. been messing with this for 14+ straight hours. You already answered (I feel dumb). Thanks, my friend. You saved me!! – josh Feb 16 '16 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.