Skip to main content

Notifications

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

How to display both Item Type and GL Type in Posted purchase invoices list page in Business central

Posted on by 76

Hi,

     Need to show item and GL description from posted purchase invoice page to Posted purchase invoices list page.

pageextension 50102 PurchaseItemDescription extends "Posted Purchase Invoices"
{
    layout
    {

        addbefore("Currency Code")
        {
            field(ItemName; ItemName)
            {
                ApplicationArea = All;
                Caption = 'Item Name';
            }
        }
    }
    trigger OnAfterGetRecord()
    var
        PurchInvLine: Record "Purch. Inv. Line";
    begin
        PurchInvLine.Reset();
        PurchInvLine.SetRange("Document No.", Rec."No.");
        PurchInvLine.SetRange(Type, PurchInvLine.Type::Item);
        if PurchInvLine.FindSet() then begin
            ItemName := PurchInvLine.Description
        end

        else
            ItemName := '';
    end;

    var
        ItemName: Text;

}
If i run the above code, I can able to show item description in posted purchase invoices list page. 
pastedimage1682490189067v1.png
I also need to show GL type description, so i added the code as:
 
PurchInvLine.SetRange(Type, PurchInvLine.Type::"G/L Account");
pastedimage1682490324154v3.png
The above screenshot showing only GL Type description. But i want to show both item and GL Type description. How to set filter or range to show both item and GL Type description?
 

 

  • Revathi.T Profile Picture
    Revathi.T 76 on at
    RE: How to display both Item Type and GL Type in Posted purchase invoices list page in Business central

    Thank you for the support. It works now. I can able to show both item and GL description using table buffer.

  • Suggested answer
    NAV_with_Narang Profile Picture
    NAV_with_Narang 2,234 Super User 2024 Season 1 on at
    RE: How to display both Item Type and GL Type in Posted purchase invoices list page in Business central

    Hi Revathi - I am not sure why anyone would want to do that, it goes against the whole design of Purchase Invoices Header & Line concept. If the customer wants to see the lines description without opening each Posted Purchase Invoice card, I'd suggest create a factbox and display it on the factbox pane of Posted Purchase Invoice list on the right hand side. Whenever the user selects a PPI 108215 on this list in the last screenshot, they'll be able to see the corresponding line descriptions on the right hand side factbox immediately without opening the card page. You can choose to also display only the description of each line in this factbox

    Even if you are able to code your necessary requirements, it will definitely backfire. I can think of many cases where the approach you are taking may absolutely not work

  • Verified answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,203 Super User 2024 Season 1 on at
    RE: How to display both Item Type and GL Type in Posted purchase invoices list page in Business central

    Hi,

    Do you mean that you want to use the same field to show both the GL Description and Item Description? For example, if the type is GLType, it shows the GL Type Description, and if the type is Item, it shows the Item Description. To achieve this, you simply need to get another table buffer for the G/L account and use it in an 'else if' condition, like this

    pastedimage1682492026261v1.png

    pastedimage1682492152621v2.png

    trigger OnAfterGetRecord()
        var
            PurchInvLine: Record "Purch. Inv. Line";
            PurchInvLine2: Record "Purch. Inv. Line";
        begin
            PurchInvLine.Reset();
            PurchInvLine2.Reset();
            PurchInvLine.SetRange("Document No.", Rec."No.");
            PurchInvLine.SetRange(Type, PurchInvLine.Type::Item);
            PurchInvLine2.SetRange("Document No.", Rec."No.");
            PurchInvLine2.SetRange(Type, PurchInvLine.Type::"G/L Account");
            if PurchInvLine.FindSet() then begin
                ItemName := PurchInvLine.Description
            end
            else
                if PurchInvLine2.FindSet() then begin
                    ItemName := PurchInvLine2.Description
                end
                else
                    ItemName := '';
        end;

    Hope it helps..

    Regards

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,056 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans