Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Field Value from Different table to another page- AL Code

(0) ShareShare
ReportReport
Posted on by 190

Dear Experts,

am Entirely new to BC and AL coding, Couple of days only i started on BC and Development Learning  

Right now am trying to bring two fields (Document No, & Description) from table (G/L Entry table - 26) to another page "Analysis View Entries" (Analysis View Entry (365)). once we click on amount in Analysis View Entries, it goes to corresponding GL entries .

i don't know whether i made code correct or not to achieve this result. 

I kindly request experts help to fix the issue

1Analysisview-entry.JPG

2glentry.JPG

pageextension 60004 PageExtension50002 extends "Analysis View Entries"
{
    layout
    {
        addafter("Dimension 1 Value Code")
        {

            field("Document No"; DocumentNo)
            {
                ApplicationArea = All;
                Caption = 'Document No';

            }
            field ("Description"; Description)
            {
                ApplicationArea = All;
                
            }

        }
    }
    trigger OnAfterGetRecord();
    var
        GenLedEntry: Record "G/L Entry";


    begin
        Clear(DocumentNo);
        GenLedEntry.Reset();
        GenLedEntry.Get(Rec."Dimension 1 Value Code");
        DocumentNo := GenLedEntry."Document No.";
        Description := GenLedEntry.Description;


    end;

    var
        DocumentNo: Code[20];
        Description : Text[100];
}



Regards

  • LearnBC Profile Picture
    LearnBC 190 on at
    RE: Field Value from Different table to another page- AL Code

    Dear Umang,

    Ya at last we crack it dear....

    Thankyou soo much for your kind Support....definitely i suggested the answer.

    really thanks

  • Verified answer
    Umang Srivastava Profile Picture
    Umang Srivastava 100 on at
    RE: Field Value from Different table to another page- AL Code

    you can write the code onaftergetrecord trigger instead of onaftergetcurrrecord.

    use onaftergetrecord trigger also suggest my answer if it works for you.

  • LearnBC Profile Picture
    LearnBC 190 on at
    RE: Field Value from Different table to another page- AL Code

    Dear Umang,

    Thank for the update

    Right now we can say we got the partial output . Means we have to select each line and go to corresponding Ledger Entry and Came back to analysis page, then only corresponding Doc no and description is coming.

    You can see in below Screen shot. first there is only 1st line of data then i clicked on 2nd line , then only 2nd doc no and description is coming. it is not coming all data in page load itself

    res1.jpg

  • Verified answer
    Umang Srivastava Profile Picture
    Umang Srivastava 100 on at
    RE: Field Value from Different table to another page- AL Code

    Hi Forgot to added the codeunit as variable kindly  use the below snippet.

    pageextension 60004 PageExtension50002 extends "Analysis View Entries"
    {
    layout
    {
    addafter("Dimension 1 Value Code")
    {
    field("Document No"; DocumentNo;)
    {
    ApplicationArea = All;
    Caption = 'Document No';
    }
    field ("Description";description;)
    {
    ApplicationArea = All;
    
    }
    }
    }
    trigger OnAfterGetCurrRecord();
    begin
    clear(DocumentNo);
    clear(Description);
    IF "Account Source" = "Account Source"::"G/L Account" THEN BEGIN
      TempGLEntry.RESET;
      TempGLEntry.DELETEALL;
      AnalysisViewEntryToGLEntries.GetGLEntries(Rec,TempGLEntry);
      tempGLEntry.findfirst;
      DocumentNo := tempglentry."Document No.";
      Description := tempglentry.Description;
    END;
    
    var
    DocumentNo: Code[20];
    Description : Text[100];
    TempGLEntry :Record	G/L Entry temporary;
    AnalysisViewEntryToGLEntries : Codeunit	AnalysisViewEntryToGLEntries;	
    }

  • LearnBC Profile Picture
    LearnBC 190 on at
    RE: Field Value from Different table to another page- AL Code

    Dear Umang

    Really appreciate for your kind help and valuable time .

    while running the code itself am getting Many errors.as a beginner i already tried many ways before posting into this forum. still its not getting the output as we expected. kindly look on this.

    Code-Error.jpg

  • Suggested answer
    Umang Srivastava Profile Picture
    Umang Srivastava 100 on at
    RE: Field Value from Different table to another page- AL Code

    Hi Kindly try this code.

    pageextension 60004 PageExtension50002 extends "Analysis View Entries"
    {
    layout
    {
    addafter("Dimension 1 Value Code")
    {
    field("Document No"; DocumentNo;)
    {
    ApplicationArea = All;
    Caption = 'Document No';
    }
    field ("Description";description;)
    {
    ApplicationArea = All;
    
    }
    }
    }
    trigger OnAfterGetCurrRecord();
    begin
    clear(DocumentNo);
    clear(Description);
    IF "Account Source" = "Account Source"::"G/L Account" THEN BEGIN
      TempGLEntry.RESET;
      TempGLEntry.DELETEALL;
      AnalysisViewEntryToGLEntries.GetGLEntries(Rec,TempGLEntry);
      tempGLEntry.findfirst;
      DocumentNo := tempglentry."Document No.";
      Description := tempglentry.Description;
    END;
    
    var
    DocumentNo: Code[20];
    Description : Text[100];
    TempGLEntry :Record	G/L Entry temporary;	
    }

  • LearnBC Profile Picture
    LearnBC 190 on at
    RE: Field Value from Different table to another page- AL Code

    Hello All,

    Still stuck on the same place.

    I have got many suggestions and modifications and all i tried from my best as a beginner. but still cant able to achieve it

    kindly requesting help on this to fix it

  • LearnBC Profile Picture
    LearnBC 190 on at
    RE: Field Value from Different table to another page- AL Code

    Hi

    No values came for both fields. only Fields are came

    .reslt.jpg

  • Suggested answer
    Umang Srivastava Profile Picture
    Umang Srivastava 100 on at
    RE: Field Value from Different table to another page- AL Code

    Hi Kindly try this code.

    pageextension 60004 PageExtension50002 extends "Analysis View Entries"

    {

    layout

    {

    addafter("Dimension 1 Value Code")

    {

    field("Document No"; GenLedEntry."Document No.";)

    {

    ApplicationArea = All;

    Caption = 'Document No';

    }

    field ("Description";GenLedEntry."Description";)

    {

    ApplicationArea = All;

    }

    }

    }

    trigger OnAfterGetCurrRecord();

    begin

    if GenLedEntry.Get(Rec."Entry No.") then;

    end;

    var

    GenLedEntry: Record "G/L Entry";

    }

  • LearnBC Profile Picture
    LearnBC 190 on at
    RE: Field Value from Different table to another page- AL Code

    Thanks for your reply.

    After  updating the last code am getting the Below Error. GL entry field issue. 

    GlError1.JPG

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,784 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,476 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans