Skip to main content

Notifications

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

Adding a custom field to Sales Header in report 1306.

Posted on by 58

Hi All,

I am new to this, so please bear with me if I have not mentioned all the information needed to get proper help. I have built a table extension that adds two custom fields to the company information table in business central. Then I added these field to a page through the page extension. The last step for me would be to add these fields to the report dataset of the sales Invoice report 1306. My work so far has the added fields present in the report dataset. The only problem seems to be that the fields, which do have a value, do not show the value.

Important Notes on what I have already looked at:

I have seen that report 1306 uses a procedure on the report Init() trigger. 

CompanyInfo.Get()

pastedimage1679330261079v7.png

Furthermore, any fields in the header are being populated by a procedure. The table header has been split into two dataItems (LeftHeader & RightHeader). I am guessing I have to subscribe to the right trigger to add my two custom fields being populated. I however, cannot seem to figure out what trigger or triggers I need to use to add my two custom fields. 

pastedimage1679330066171v2.png

This goes back to the FillLeftHeader() Procedure

 pastedimage1679330185259v6.png

The code I wrote is below:

Table Extension

tableextension 50100 CribNoExt extends "Company Information"
{

    fields
    {
        // Add changes to table fields here
        field(101; Company_Crib_No; Text[20])
        {
            Caption = 'Crib No.';
        }
        field(102; Company_Kvk_No; Text[20])
        {
            Caption = 'Kvk No.';
        }
        field(103; "Bank Name 2"; Text[20])
        {
            Caption = 'Bank Name 2';
        }
        field(104; "Bank Account No 2"; Text[20])
        {
            Caption = 'Bank Account No 2';
        }
    }

    var
        myInt: Integer;
}
 

Page extension:

pageextension 50102 CribNoPage extends "Company Information"
{
    layout
    {
        // Add changes to page layout here
        addafter("Industrial Classification")
        {
            field(CribNo; Rec.Company_Crib_No)
            {
                ApplicationArea = all;
            }
            field(KvkNo; Rec.Company_Kvk_No)
            {
                ApplicationArea = all;
            }
        }

        addafter("Bank Account No.")
        {
            field("Bank Name 2"; Rec."Bank Name 2")
            {
                ApplicationArea = all;
            }
            field("Bank Account No 2"; Rec."Bank Account No 2")
            {
                ApplicationArea = all;
            }
        }
    }

    actions
    {
        // Add changes to page actions here
    }

    var
        myInt: Integer;
}

Report Extension:

reportextension 50103 CribNoKvK extends "Standard Sales - Invoice"
{

    dataset
    {
        // Add changes to dataitems and columns here

        add(Header)
        {
            column(Company_Crib_No; companyInfoExt.Company_Crib_No) { }
            column(Company_Kvk_No; companyInfoExt.Company_Kvk_No) { }
        }

    }
    
    Var
        myInt: Integer;
        myCribNo: text[20];
    
        companyInfoExt: Record "Company Information";
        company_crib_no_lbl: Label 'Crib No';
        company_kvk_no_lbl: Label 'Kvk No';

}

IN conclusion I want to know is this possible? and if not is the only other solution to create a completely new report? This is quite a complex report to just copy and then edit. I would rather extend it. 

  • Zafar LIT Profile Picture
    Zafar LIT 58 on at
    RE: Adding a custom field to Sales Header in report 1306.

    Thank you NorthW for the explanation and reference!

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Adding a custom field to Sales Header in report 1306.

    Maybe this is helpful ?

    learn.microsoft.com/.../devenv-get-find-and-next-methods

    Normally when you use the Get method you will add parameters for the primary key of the record you want to get.

    But if you use Get.() with no parameteres the function will get the first record in the table. And because there are only one record in the companyinformation table the get.() with out parameteres will work fine here.

  • Zafar LIT Profile Picture
    Zafar LIT 58 on at
    RE: Adding a custom field to Sales Header in report 1306.

    NorthW It worked!

    Do you have a reference for me for the .get() function? I did not get that the .Get() (method or function) is a standard function of some sort. Which made it a lot more complicated for me to figure out.

    In any case this is the solution to my problem! Thank yo very much!

  • Zafar LIT Profile Picture
    Zafar LIT 58 on at
    RE: Adding a custom field to Sales Header in report 1306.

    Hi NorthW ,

    Thank for the reply. I will try this and circle back if that worker for me.

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Adding a custom field to Sales Header in report 1306.

    You need to run  a get on your CompanyInfoExt variable in a on pre report trigger as described here.

    Try to add that trigger to your report and do a CompanyInfoExt.Get() within that trigger.

    You can do this in a learn.microsoft.com/.../devenv-onprereport-report-trigger

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!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans