Skip to content

Conversation

@diveshbora
Copy link

@diveshbora diveshbora commented Nov 10, 2025

Summary

This pull request extends the System Application Translation module with a new public API for programmatic retrieval of translation data, addressing the requirements of partners and ISVs for custom translation workflows and data integration scenarios.

Current Gap: The existing Translation module API lacks bulk retrieval capabilities needed for:

  • Adding translation to the custom tables and workflows
  • Exporting translations for external processing

Technical Approach

Introduces a read-only query API following established System Application patterns, returning results via a temporary buffer table to ensure no database impact and maintain performance standards.

API Design

Public Procedure: GetTranslations

Location: codeunit 3711 "Translation" (System Application)

Signature:

procedure GetTranslations(RecVariant: Variant; FieldId: Integer; var TranslationBuffer: Record "Translation Buffer"): Boolean

Parameters:

Parameter Type Description
RecVariant Variant Source record (supports Record, RecordRef, or RecordId)
FieldId Integer Field number to query (0 = all fields)
TranslationBuffer Record "Translation Buffer" (var) Output buffer populated with results

Returns: Boolean - True if translations found, False otherwise

Design Rationale:

  • Variant parameter - Maintains consistency with existing Translation.Set() and Translation.Get() APIs
  • Temporary buffer output - Enables efficient batch processing without database writes
  • Boolean return - Provides explicit success/failure indication for error handling
  • Zero FieldId convention - Allows bulk retrieval across all translated fields

Work Item(s)

Fixes #5434

@diveshbora diveshbora requested a review from a team as a code owner November 10, 2025 09:55
@github-actions github-actions bot added AL: System Application From Fork Pull request is coming from a fork labels Nov 10, 2025
@github-actions
Copy link

Issue #5434 is not valid. Please make sure you link an issue that exists, is open and is approved.

@diveshbora diveshbora changed the title [BC Idea]: Add GetTranslations Method to Translation Codeunit #5434 [BC Idea]: Add GetTranslations Method to Translation Codeunit Nov 10, 2025
@diveshbora
Copy link
Author

@diveshbora please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement
@microsoft-github-policy-service agree company="Microsoft"

@JesperSchulz JesperSchulz added the Integration GitHub request for Integration area label Nov 10, 2025
Copy link
Contributor

@pri-kise pri-kise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add some tests:

    [Test]
    [Scope('OnPrem')]
    procedure GetTranslationsForOneFieldFromRecord()
    var
        TranslationTestTable: Record "Translation Test Table";
        TranslationBuffer: Record "Translation Buffer"
        DestRecRef: RecordRef;
        SourceRecRef: RecordRef;
    begin
        // [SCENARIO] Translation must retrieved correctly for one field

        Initialize();
        PermissionsMock.Set(TranslationEditRoleTok);

        // [GIVEN] Create a record in TableA and set a translation for the fields FieldA and FieldB
        CreateRecord(TranslationTestTable);
        Translation.Set(TranslationTestTable, TranslationTestTable.FieldNo(TextField), Text1Txt);
        Translation.Set(TranslationTestTable, TranslationTestTable.FieldNo(SecondTextField), Text2Txt);

        // [WHEN] Translations are retrieved
        Translation.GetTranslations(SourceRecRef, TranslationTestTable.FieldNo(TextField), TranslationBuffer);

        // [THEN] Verify Translations
        //TODO:
    end;
    [Test]
    [Scope('OnPrem')]
    procedure GetTranslationsForAllFieldsFromRecord()
    var
        TranslationTestTable: Record "Translation Test Table";
        TranslationBuffer: Record "Translation Buffer"
        DestRecRef: RecordRef;
        SourceRecRef: RecordRef;
    begin
        // [SCENARIO] Translation must retrieved correctly for all fields when FieldId is 0 

        Initialize();
        PermissionsMock.Set(TranslationEditRoleTok);

        // [GIVEN] Create a record in TableA and set a translation for the fields FieldA and FieldB
        CreateRecord(TranslationTestTable);
        Translation.Set(TranslationTestTable, TranslationTestTable.FieldNo(TextField), Text1Txt);
        Translation.Set(TranslationTestTable, TranslationTestTable.FieldNo(SecondTextField), Text2Txt);

        // [WHEN] Translations are retrieved
        Translation.GetTranslations(SourceRecRef, 0, TranslationBuffer);

        // [THEN] Verify Translations
        //TODO:
    end;

@diveshbora diveshbora force-pushed the feature/translation-GetTranslation-BC27 branch from d4a92bc to b240658 Compare November 11, 2025 16:45
@diveshbora diveshbora force-pushed the feature/translation-GetTranslation-BC27 branch 3 times, most recently from c671d47 to 24ea1c8 Compare November 17, 2025 06:01
@diveshbora
Copy link
Author

@JesperSchulz Apologies for the inconvenience, but could we please expedite this?

…nslation Buffer table

Add a new procedure GetTranslations to the Translation Implementation codeunit for retrieving translations based on record variants and field IDs. Introduce a new Translation Buffer table to store translation data temporarily, including fields for Language ID, System ID, Table ID, Field ID, and Value. This enhances the translation functionality by allowing retrieval of translations for specific fields or all fields when FieldId is 0.
@diveshbora diveshbora force-pushed the feature/translation-GetTranslation-BC27 branch from 24ea1c8 to 489a226 Compare November 19, 2025 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: System Application From Fork Pull request is coming from a fork Integration GitHub request for Integration area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants