Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

How to update fields using action button?

Posted on by 160

8308.Capture.PNG

I want to update Payment,balance,Net change fields by using Action Button on page.

I used below mentioned code. but its updating Name, adress and "No." Fields only.

trigger OnAction();
                var
                    customer: Record Customer;
                    cust: Record CustTable;
                begin
                    cust.Reset();
                    DeleteAll();
                    Customer.findset;

                    repeat

                        Cust."No." := customer."No.";
                        cust.Name := customer.Name;
                        cust.Address := customer.Address;
                        cust.Balance := customer.Balance;
                        cust.NetChange := customer."Net Change";
                        cust.Payments := customer.Payments;
                        cust."Balance Due" := customer."Balance Due";
                        cust.insert;

                    until customer.next = 0;

                end;

Capture.PNG_2D00_640x480.png

Categories:
  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: How to update fields using action button?

    A bit hard to overlook with only seeing part of your AL code.

    Are any of the fields i the CustTable defined as flowfields?

    If so you need to make them ordinary fields if you want to use your approach.

    You probably get the error because your are trying to assign a value to a flowfield.

    But i still think you should create your page with the Customer table as your source table instead of your CustTable as the source table.

  • happysingh0009 Profile Picture
    happysingh0009 160 on at
    RE: How to update fields using action button?

    After trying your solution, i get this message

    "A flow field is part of the query column list, this is not supported"

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: How to update fields using action button?

    Some of the fields you are using here are flowfields so you need to do a calcfields(Balance,"Net Change",Paymentys,"Balance Due");

    Before you can use the values of those fields.

    Put the calcflields command on the top of your repeat loop. f.ex.

    But why are you using a spesific CustTable and not the customer record directly in your form?

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,647 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans