Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Certified Platform Developer II All Questions

View all questions & answers for the Certified Platform Developer II exam

Exam Certified Platform Developer II topic 1 question 5 discussion

Actual exam question from Salesforce's Certified Platform Developer II
Question #: 5
Topic #: 1
[All Certified Platform Developer II Questions]

A company has code to update a Request and Request Lines and make a callout to their external ERP system's REST endpoint with the updated records.

The CalloutUtil.makeRestCallout fails with a 'You have uncommitted work pending. Please commit or rollback before calling out' error.
What should be done to address the problem?

  • A. Remove the Database.setSavepoint and Database.rollback.
  • B. Change the CalloutUtil.makeRestCallout to an @InvocableMethod method.
  • C. Change the CalloutUtil.makeRestCallout to an @future method.
  • D. Move the CalloutUtil.makeRestCallout method call below the catch block.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
rufusroffie
Highly Voted 1 year, 8 months ago
Selected Answer: C
B is definitely incorrect because InvocableMethod can only take a list of primitive data type/sobject type/generic sobject type/variables, in conclusion, the input parameter is always a LIST; C is correct because map.keySet() returns a set of key in this case a set of Id, which is not even sobject. -Methods with the future annotation must be static methods, and can only return a void type. The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types. Methods with the future annotation can’t take sObjects or objects as arguments A literally does nothing here, and D is obviously wrong lmao
upvoted 6 times
...
chrisx01
Most Recent 1 year, 7 months ago
C https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htm global class FutureMethodRecordProcessing { @future public static void processRecords(List<ID> recordIds) { // Get those records based on the IDs List<Account> accts = [SELECT Name FROM Account WHERE Id IN :recordIds]; // Process records } }
upvoted 3 times
...
rhea90
1 year, 9 months ago
Ans: A Ref: Callouts are not allowed when there is an uncommitted transaction pending. For example, if a save point is set before a DML operation, a callout cannot be made based on the results of that operation to commit or roll back the save point https://help.salesforce.com/s/articleView?id=000385708&type=1
upvoted 1 times
Shinchan9
8 months, 1 week ago
In that case D could be valid answer
upvoted 1 times
...
...
karappo
1 year, 9 months ago
Selected Answer: B
B since future method can't take sobjects as parameter
upvoted 1 times
santo_aj
1 year, 5 months ago
Option B is not valid since the callable method would still give the same error. The correct option is C, it is necessary to make changes and pass the list of identifiers to the future method and build the maps in it.
upvoted 1 times
...
...
Sappaul
3 years, 5 months ago
C is right answer
upvoted 4 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.

SaveCancel
Loading ...