A company has a web page that needs to get Account record information, given its Salesforce record ID, from JavaScript on the page and then display it. Which method of integration is optimal?
D is correct:
The requirement is to fetch Account record information from JavaScript on a web page, which means the request will be made from a client-side script (JavaScript).
Apex REST Web Service allows the creation of custom REST endpoints in Salesforce using Apex.
JavaScript can easily call an Apex REST Web Service using AJAX or Fetch API.
A can be done but it's not optimal. While Salesforce provides a standard REST API, it requires authentication via OAuth, which can be complex to handle in JavaScript running in a browser. Apex REST allows more control and customization.
The key difference between D vs A is control and authentication complexity. Due to the complexity of authentication via JavaScript, D is the optimal answer.
I'd say D
https://trailhead.salesforce.com/content/learn/modules/apex_integration_services/apex_integration_webservices
"By making your methods callable through the web, your external applications can integrate with Salesforce to perform all sorts of nifty operations."
A web page that needs to retrieve account info from SF sounds like an external application to me,
I said D myself, but I think the confusion comes from that cast that I thought 'Rest API' implied that Salesforce was using a callout to an external service whereas the external service is using the API (without a custom class) to get the information. The reason why it mentions Javascript is because REST supports JSON whereas SOAP does not, it only supports XML.
The correct is A you don't need to expose the apex rest service and write a test class for just retrieving an account, just call a rest API https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_get_field_values.htm
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
nibbio
Highly Voted 3 years, 4 months agoBrainMelt12
Most Recent 1 month, 1 week agogsori
8 months, 3 weeks agothneeb
2 years, 2 months agolorenac2
2 years, 3 months agoamilaveer
2 years, 4 months agoRonin192
2 years, 5 months agonkarmi
2 years, 5 months agolevian
2 years, 6 months agoOmShantiVeg
2 years, 9 months ago