Question 580
A background job calls an external service that sometimes fails and must log the exception without corrupting an ongoing transaction. A targeted trial still reproduces the original gap after the team attempted this change: Use an appropriate guarded AL error-handling pattern and preserve transactional safety. Which repair directly addresses the remaining defect?
Explanation
Correct Answer
Move database writes out of the TryFunction and adjust the guarded caller so a handled failure leaves no partial changes. This directly addresses the remaining defect for the requirement—A background job calls an external service that sometimes fails and must log the exception without corrupting an ongoing transaction. It restores the mechanism described here: a tryfunction can catch an expected error, but it does not automatically roll back database writes; the surrounding code must preserve transaction consistency.
Incorrect Answers
This correction is for the separate condition: A stock process should update only records in one location but loops through every warehouse item. It would not directly restore the intended behavior in this situation: A background job calls an external service that sometimes fails and must log the exception without corrupting an ongoing transaction. Here, move database writes out of the tryfunction and adjust the guarded caller so a handled failure leaves no partial changes, because a tryfunction can catch an expected error, but it does not automatically roll back database writes; the surrounding code must preserve transaction consistency.
This correction is for the separate condition: A posting reconciliation visits only the first matching invoice instead of iterating the full result set. It would not directly restore the intended behavior in this situation: A background job calls an external service that sometimes fails and must log the exception without corrupting an ongoing transaction. Here, move database writes out of the tryfunction and adjust the guarded caller so a handled failure leaves no partial changes, because a tryfunction can catch an expected error, but it does not automatically roll back database writes; the surrounding code must preserve transaction consistency.
This correction is for the separate condition: A document import needs to generate an export stream for a user to download from Business Central online. It would not directly restore the intended behavior in this situation: A background job calls an external service that sometimes fails and must log the exception without corrupting an ongoing transaction. Here, move database writes out of the tryfunction and adjust the guarded caller so a handled failure leaves no partial changes, because a tryfunction can catch an expected error, but it does not automatically roll back database writes; the surrounding code must preserve transaction consistency.





Microsoft Dynamics 365 Business Central Developer (MB-820) Practice Tests