-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IncludeSender in Format Address subscriber and add a GetLanguageCode() procedure. #26293
Comments
Can you be more specific with example of events you are referring to? And how they should be changed? |
Hi, @Groenbech96 For example in the // dataitem("Sales Shipment Header"; "Sales Shipment Header")
trigger OnAfterGetRecord()
begin
CurrReport.Language := LanguageMgt.GetLanguageIdOrDefault("Language Code");
CurrReport.FormatRegion := LanguageMgt.GetFormatRegionOrDefault("Format Region");
FormatAddr.SetLanguageCode("Language Code"); // Language Code is passed into the Format Address Codeunit
FormatAddressFields("Sales Shipment Header");
FormatDocumentFields("Sales Shipment Header");
if not CompanyBankAccount.Get("Sales Shipment Header"."Company Bank Account Code") then
CompanyBankAccount.CopyBankFieldsFromCompanyInfo(CompanyInfo);
DimSetEntry1.SetRange("Dimension Set ID", "Dimension Set ID");
end;
local procedure FormatAddressFields(SalesShipmentHeader: Record "Sales Shipment Header")
begin
FormatAddr.GetCompanyAddr(SalesShipmentHeader."Responsibility Center", RespCenter, CompanyInfo, CompanyAddr);
FormatAddr.SalesShptShipTo(ShipToAddr, SalesShipmentHeader);
ShowCustAddr := FormatAddr.SalesShptBillTo(CustAddr, ShipToAddr, SalesShipmentHeader);
end; The procedure The procedure and publisher look like this: procedure SalesShptShipTo(var AddrArray: array[8] of Text[100]; var SalesShptHeader: Record "Sales Shipment Header")
var
Handled: Boolean;
begin
OnBeforeSalesShptShipTo(AddrArray, SalesShptHeader, Handled); // Missing LanguageCode
if Handled then
exit;
FormatAddr(
AddrArray, SalesShptHeader."Ship-to Name", SalesShptHeader."Ship-to Name 2", SalesShptHeader."Ship-to Contact", SalesShptHeader."Ship-to Address", SalesShptHeader."Ship-to Address 2",
SalesShptHeader."Ship-to City", SalesShptHeader."Ship-to Post Code", SalesShptHeader."Ship-to County", SalesShptHeader."Ship-to Country/Region Code");
end;
[IntegrationEvent(false, false)]
local procedure OnBeforeSalesShptShipTo(var AddrArray: array[8] of Text[100]; var SalesShipmentHeader: Record "Sales Shipment Header"; var Handled: Boolean)
begin
end; This could be, in my opinion, fixed by either adding the global Let me know if you need any more details. Milan |
PS: As for why we can't just use the Language Code from the document - please refer to Additional Context of my original submission. |
Is there a way for you to use existing OnAfterFormatAddress? |
The It's also called after the code so to avoid duplicitous calling of all the formatting functions, For example (this is not our case) if we had custom fields in the Company Information just for printing alternative company address for foreign customers, because the normal local address normally contains some weird characters with accents or whatever, and wanted to hijack the The only way to do it correctly is to hijack the |
Do you have the list of events that you would need the LanguageCode added to? |
Describe the request
The
codeunit 365 "Format Address"
has publishers in all of its functions likeCompany
,Customer
, etc, which allow global customization of how the addresses are structured.Unfortunately, these events do not contain the
Language Code
property, which is a problem, because the codeunit is not using the global language, but the language usually set on the record (when calling from a report).So when the function is bypassed (using
IsHandled = true
), there is no way how to translate the country or other information correctly using the currently set LanguageCode.I suggest either:
LanguageCode
to the publishers, orIncludeSender = true
and add aGetLanguageCode
global proceduresender.FormatAddr()
, since that is already global, and not worry about the Language Code, in cases where we only change the information that is sent, not its order.Additional context
In our customizations, we sometimes change the language code on factors other then the Language Code of the printed document, like manually changing the language from the request page. So we can't rely on the Language Code of the document that is sent to the function.
In some cases (like
Company
), there even is no Language Code. Adding the country to the company address is a frequent request of our customers and we currently can't simply add it using a single subscriber, because of the language code.Internal work item: AB#525470
The text was updated successfully, but these errors were encountered: