Question 170
At fictional Xenon Office Supply, the Business Central development team is supporting office stock replenishment and reviewing object model and application extensibility during a troubleshooting exercise (MB820-3.4-093). The observed development issue is that a lookup procedure mutates a global variable and returns inconsistent results when reused across sessions. Which AL development or design response most directly addresses this issue?
Explanation
Correct Answer
The most direct corrective response is to refactor it to accept explicit inputs and return a well-defined result without hidden mutable dependencies. This addresses the specific failure where a lookup procedure mutates a global variable and returns inconsistent results when reused across sessions. Acceptance evidence is that repeated calls with the same inputs produce consistent values.
Incorrect Answers
“Use available integration events and a subscriber or suitable extension point” supports the separate task “use available integration events and a subscriber or suitable extension point”, not the reported problem: a lookup procedure mutates a global variable and returns inconsistent results when reused across sessions. This case instead calls for “refactor it to accept explicit inputs and return a well-defined result without hidden mutable dependencies”.
“Define an AL interface and implement it in separate codeunits with a supported dispatch pattern” concerns the alternative task “define an AL interface and implement it in separate codeunits with a supported dispatch pattern”, but the stated failure is that a lookup procedure mutates a global variable and returns inconsistent results when reused across sessions. The required measure is to refactor it to accept explicit inputs and return a well-defined result without hidden mutable dependencies.
The proposed “Use distinct Install and Upgrade codeunits, implementing the appropriate lifecycle triggers” tests a different control: use distinct Install and Upgrade codeunits, implementing the appropriate lifecycle triggers. The reported condition is that a lookup procedure mutates a global variable and returns inconsistent results when reused across sessions; the more direct action is to refactor it to accept explicit inputs and return a well-defined result without hidden mutable dependencies.