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 4
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";
}
_______________________________________________________________________________________
 
 
 
 
  • Suggested answer
    Suresh Kulla Profile Picture
    45,725 on at
    VS Says there is error in code.. What are my options:
    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];
    }
  • Suggested answer
    YUN ZHU Profile Picture
    79,334 Super User 2025 Season 1 on at
    VS Says there is error in code.. What are my options:
    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
    Saurav.Dhyani Profile Picture
    14,312 Super User 2025 Season 1 on at
    VS Says there is error in code.. What are my options:
    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.
     

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,011 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans