function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Joshua FeistJoshua Feist 

Better visualization of JSON data

Hi,

I'm trying to figure out if it's possible to take some JSON code produced with a button push on an Account object and convert it into something that's easier on the eyes. I've found something that does this fairly well and I'm looking for Salesforce to do something similar.

Is it possible to make a custom button that does and API call to retrieve data from an external database and then display it in a table? If so, can someone help me get the ball rolling with the code?

Currently, the button is just a URL and I'm passing in one parameter:  https://api.data.gov/sam/v1/registrations?api_key=(insertkeyhere)&qterms=duns:{!Account.DUNS_Number__c}

I think I would need to change the button's Content Source to Javascript or VisualForce page?
pconpcon
You would need to create a custom Visualforce page with a custom controller extension [1].  You will want to make a apex callout [2] to  your endpoint and then store that data and display it in an table on the page. I'd look at using apex:dataTable [3] for the best results.

[1] https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_extension.htm
[2] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts.htm
[3] https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_dataTable.htm