New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Certified Platform Developer II (Plat-Dev-301) Exam - Topic 2 Question 107 Discussion

Actual exam question for Salesforce's Salesforce Certified Platform Developer II (Plat-Dev-301) exam
Question #: 107
Topic #: 2
[All Salesforce Certified Platform Developer II (Plat-Dev-301) 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 callousUtil.makeRestCallout fails with a "You have uncommitted work pending. Please commit or rollback before calling cut' error.

What should be done to address the problem?

Show Suggested Answer Hide Answer

Contribute your Thoughts:

0/2000 characters
Giuseppe
3 months ago
Totally agree with option A, it makes sense to use @InvocableMethod.
upvoted 0 times
...
Gearldine
3 months ago
Wait, can you really just remove the rollback? That seems risky!
upvoted 0 times
...
Mira
3 months ago
@future method could work too, but not sure if it's the best choice.
upvoted 0 times
...
Joni
4 months ago
I think option B is the way to go!
upvoted 0 times
...
Karina
4 months ago
Sounds like a classic uncommitted work issue.
upvoted 0 times
...
Rueben
4 months ago
I'm a bit confused about the implications of each option; I feel like I need more clarity on when to use @InvocableMethod versus @future.
upvoted 0 times
...
Lavonda
4 months ago
I practiced a similar question where using @future methods helped with callouts, so maybe option C could work here too.
upvoted 0 times
...
Noemi
4 months ago
I think removing the Database.setSavepoint and rollback might solve the issue, but I need to double-check if that affects data integrity.
upvoted 0 times
...
Joaquin
5 months ago
I remember studying about the uncommitted work error, but I'm not sure if changing to @InvocableMethod is the right approach here.
upvoted 0 times
...
Benedict
5 months ago
I'm a bit unsure about the difference between @InvocableMethod and @future methods. I'll need to review the documentation to make sure I understand the implications of each option.
upvoted 0 times
...
Malcolm
5 months ago
This is a good example of how transaction management can trip you up when integrating with external systems. I'll need to be really careful to handle that properly in my solution.
upvoted 0 times
...
Alesia
5 months ago
I think the key here is to figure out where the transaction is being managed and how to properly commit or roll it back before making the REST callout. Option B looks promising, but I'll need to double-check the details.
upvoted 0 times
...
Marquetta
5 months ago
Okay, the error message mentions "uncommitted work pending." That sounds like an issue with the transaction management. I'll need to think through the options to address that.
upvoted 0 times
...
Belen
5 months ago
Hmm, this looks like a tricky one. I'll need to carefully read through the code and error message to understand what's going on.
upvoted 0 times
...
Germaine
9 months ago
I'm going with option B. Removing the savepoint and rollback sounds like the logical fix. Although, I can't help but imagine the developer who wrote this code must have had a really hard time with their keyboard. 'callousUtil' indeed!
upvoted 0 times
Felicidad
8 months ago
Definitely, simplifying the code can help avoid these kinds of errors in the future.
upvoted 0 times
...
Lindy
8 months ago
Yeah, it's important to keep the code clean and efficient.
upvoted 0 times
...
Josephine
8 months ago
I agree, it's probably the most straightforward solution to the problem.
upvoted 0 times
...
Ethan
8 months ago
Option B seems like the best choice. Removing the savepoint and rollback should fix the issue.
upvoted 0 times
...
...
Dana
10 months ago
Option B is the way to go here. Removing the savepoint and rollback calls should resolve the issue. Although, I can't help but wonder - who named this method 'callousUtil'? Seems a bit on the nose, don't you think?
upvoted 0 times
Herman
9 months ago
Yeah, the name 'callousUtil' does seem a bit harsh for a method dealing with REST callouts.
upvoted 0 times
...
Glenna
9 months ago
I agree, changing the callousUtil method to an @future method might also work.
upvoted 0 times
...
Daniel
9 months ago
Option B is the way to go here. Removing the savepoint and rollback calls should resolve the issue.
upvoted 0 times
...
...
Alishia
10 months ago
Hmm, turning the makeRestCallout into an @future method might work, but it seems like a bit of a band-aid solution. I'd go with option B and remove the savepoint and rollback calls. That way, the transaction can be properly committed before the callout is made.
upvoted 0 times
Micah
9 months ago
I think removing the savepoint and rollback calls is the safer option.
upvoted 0 times
...
Jimmie
9 months ago
But wouldn't changing the makeRestCallout to an @future method also work?
upvoted 0 times
...
Chandra
9 months ago
I agree, removing the savepoint and rollback calls seems like the best solution.
upvoted 0 times
...
...
Roosevelt
10 months ago
This is a tricky one. The error message indicates that there is some outstanding work that needs to be committed before the callout can be made. Option B seems like the right fix, as it removes the savepoint and rollback, which could be causing the issue.
upvoted 0 times
Rebeca
9 months ago
Let's go ahead and make that change and see if it resolves the error.
upvoted 0 times
...
Shawna
9 months ago
I agree, removing the savepoint and rollback should fix the issue.
upvoted 0 times
...
Tanesha
9 months ago
I think option B is the best solution here.
upvoted 0 times
...
...
Kenneth
11 months ago
Hmm, I think the issue here is that the makeRestCallout method is being called before the transaction is committed. Changing it to an @InvocableMethod won't solve the problem, as the error is still related to the uncommitted work. I'd go with option B - removing the savepoint and rollback calls.
upvoted 0 times
Willie
9 months ago
Makes sense, thanks for clarifying.
upvoted 0 times
...
Tawna
9 months ago
I don't think so, the issue is with the uncommitted work, so removing the savepoint and rollback is the way to go.
upvoted 0 times
...
Janae
9 months ago
But wouldn't changing the makeRestCallout to an @future method also work?
upvoted 0 times
...
Jacquelyne
10 months ago
I agree, removing the savepoint and rollback calls seems like the best solution.
upvoted 0 times
...
...
Avery
11 months ago
But wouldn't removing the Database.setSavepoint and Database.rollback also solve the issue?
upvoted 0 times
...
Tracey
11 months ago
I agree with Kristofer. Using an @future method will prevent the 'uncommitted work pending' error.
upvoted 0 times
...
Kristofer
11 months ago
I think we should change the CallousUtil.makeRestCallout to an @future method.
upvoted 0 times
...

Save Cancel