Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

How to calculate the sum of 2 fields in my sales order?

Posted on by 422

So i've created a field in my sales order of type decimal.

I want to have the sum of that field and the "Qty. to ship" field on that row. Now i looked into calcsums but i can't seem to figure out on how to use this.

After I want to check if the value is greater than the "Quantity" field.

Is there a way to accomplish this in AL code?

EDIT:

I found out that the fields are flowfields so that i need to calculate the value of a flowfield using Rec.CalcFields(Amount, "Qty. to ship") for example. Now the only problem i have now when i perform this action on this field it gives me an error that the amound field in the sales line must be a flowfield...

Any help is welcome

*This post is locked for comments

  • Suggested answer
    TeddyH Profile Picture
    TeddyH 12,868 Super User 2024 Season 1 on at
    RE: How to calculate the sum of 2 fields in my sales order?

    You can only do calcfield if your field is a flowfield. Amount and Qty. to ship are not flow field. Just normal field.

    You can do CALCSUM only if the field is specified as SumIndexFields in the table (Sales Line) table. Amount should be listed as SumIndexFields, but I don't think "Qty. to ship" is listed.

    Check this for reference.

    docs.microsoft.com/.../calcsums-function--record-

    Or just do the old fashion way. Do a loop and sum it manually.

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans