Why do you need this change?
GetHeaderLocationCode uses a case statement to return the location code from the appropriate source record for each WhseDoc value. The base case has an else branch that returns SourceLocationCode as a fallback for any unrecognised WhseDoc value. Custom document types such as "Staged Pick" have their own source record (WhseStagedPickLine) whose "Location Code" must be returned instead. Because the else branch silently returns SourceLocationCode, the wrong location code is used downstream without any error, making this failure mode difficult to detect.
There is no event before/after the case statement that allows subscribers to apply custom code or exit the procedure early for custom WhseDoc values.
Describe the request
Add OnAfterGetHeaderLocationCode at the very end of case block so subscribers can also populate custom case.
local procedure GetHeaderLocationCode(): Code[10]
begin
case WhseDoc of
WhseDoc::"Put-away Worksheet",
WhseDoc::"Whse. Mov.-Worksheet":
exit(WhseWkshLine."Location Code");
else
exit(SourceLocationCode);
end;
OnAfterGetHeaderLocationCode(WhseDoc, LocationCode) // ← event added here
end;
Event Signature:
[IntegrationEvent(false, false)]
local procedure OnAfterGetHeaderLocationCode(
WhseDoc: Option;
var LocationCode: Code[10];)
begin
end;
Alternatives evaluated:
This can also be achieved by raising an integration event with IsHandled before the case block — when a subscriber sets
IsHandled := true, the procedure exits immediately, allowing custom code to execute. No event currently exists in GetHeaderLocationCode that exposes WhseDoc and allows subscriber to override the return value before the case executes.
Why do you need this change?
GetHeaderLocationCodeuses acasestatement to return the location code from the appropriate source record for eachWhseDoc value. The basecasehas anelse branchthat returnsSourceLocationCodeas a fallback for any unrecognisedWhseDocvalue. Custom document types such as "Staged Pick" have their own source record (WhseStagedPickLine) whose "Location Code" must be returned instead. Because the else branch silently returns SourceLocationCode, the wrong location code is used downstream without any error, making this failure mode difficult to detect.There is no event before/after the case statement that allows subscribers to apply custom code or exit the procedure early for custom
WhseDocvalues.Describe the request
Add
OnAfterGetHeaderLocationCodeat the very end ofcaseblock so subscribers can also populate custom case.Event Signature:
Alternatives evaluated:
This can also be achieved by raising an integration event with
IsHandledbefore thecaseblock — when a subscriber setsIsHandled := true, the procedure exits immediately, allowing custom code to execute. No event currently exists inGetHeaderLocationCodethat exposesWhseDocand allows subscriber to override the return value before the case executes.