web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

VS Says there is error in code.. What are my options:

(1) ShareShare
ReportReport
Posted on by 12
As a beginner, I asked copilot to look at my code and suggest an alternative and it gave me this code. I want to add the vendor payment terms code to the AP Aging Report.
 
Visual studio says that there are many missing brackets on the line of my first "column" statement highlighted in yellow below. I have even tried saving the code as a text file and I tried to create a new page and retyping the code but the error keeps coming up. I have an image of the error attached as well.
 
 
reportextension 50105 APAgingExtension extends "Aged Accounts Payable"
{
    RDLCLayout = 'AgedAccountsPayable.rdlc';
    dataset
    {
        modify(Vendor)
        {
            column(Payment_Terms_Code; "Payment Terms Code")
            { 
                // Column to show the payment terms code from Vendor.
            }
            column(Payment_Terms_Description; PaymentTerms.Description)
            { 
                // Column to show the description from Payment Terms record.
            }
            trigger OnAfterGetRecord()
            begin
                PaymentTerms.Get("Payment Terms Code");
            end;
        }
    }
    labels
    {
        PaymentTerm = 'Payment Terms';
        PaymentTermDescription = 'Terms Description';
    }
    var
        PaymentTerms: Record "Payment Terms";
}
_______________________________________________________________________________________
 
 
 
 
Screenshot 2025-02-15 002859.png
I have the same question (0)
  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,380 Super User 2025 Season 2 on at
    Hi,
     
    Don't reply on copilot.
     
    It's there to support you if you know how to do it.
     
    Read Documentation on how to extend a standard report in VS Code. That will tell you what mistake you are doing.
     
  • Suggested answer
    YUN ZHU Profile Picture
    95,748 Super User 2025 Season 2 on at
    Totally agree with Saurav, it takes longer to fix a piece of code you wrote using Copilot than to rewrite it from scratch...
     
    It looks like you want to do the following, hope this can give you some hints.
     
    Thanks.
    ZHU
  • Suggested answer
    Suresh Kulla Profile Picture
    50,247 Super User 2025 Season 2 on at
    As others mentioned you can't reply completely on CoPilot to write your code, it is to help you to write code faster if you know how to write it. Anyhow there are two issue in the above code instead of Modify(Vendor) it should be Add(Vendor) since you are adding fields. I believe the below version should fix the error
     
    reportextension 50105 APAgingExtension extends "Aged Accounts Payable"
    {
        RDLCLayout = 'AgedAccountsPayable.rdlc';
        dataset
        {
            add(Vendor)
            {
               
                column(Payment_Terms_Code; "Payment Terms Code")
                {
                }
                column(Payment_Terms_Description;PaymentTerms.Description)
                {
                }
               
            }
            modify(Vendor)
            {
                trigger OnAfterAfterGetRecord()
                begin
                    PaymentTerms.Get(Vendor."Payment Terms Code");
                end;
            }
        }
        labels
        {
            PaymentTerm = 'Payment Terms';
            PaymentTermDescription = 'Terms Description';
        }
        var
            PaymentTerms: Record "Payment Terms";
            PaymentTermsDescription: Text[30];
    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,092

#2
YUN ZHU Profile Picture

YUN ZHU 663 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 515

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans