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

Getting error while setting value in Inv. Discount Amount Excl. Tax (USD) of sales order

(0) ShareShare
ReportReport
Posted on by 259

Hi, 

I am setting value in Inv. Discount Amount Excl. Tax (USD) of sales order from code.

af.png

But I am getting below error.

The primary key in the Sales Line table can contain only one field, and its type must be Integer

Here is my codeunit which I am using to update.

salesorderDiscountUpdate.Reset();
salesorderDiscountUpdate.setRange("No.", 'SP000004');
if salesorderDiscountUpdate.FindFirst() then begin
salesorderDiscountUpdate.Validate("Invoice Discount Amount", 2);
salesorderDiscountUpdate.Modify(true);
end;

I have the same question (0)
  • Suggested answer
    JAngle Profile Picture
    133 on at

    Is the target the sales header? You don’t have the primary key in the setrange. Header is document type and then number.

  • Danyal Profile Picture
    259 on at

    Hi Josh, yes target table is sales header.

    The process is, you have an order with one or more lines. Set a value in Inv. Discount Amount Excl. Tax (USD) e.g. 5 as highlighted in attached screenshot. Setting value in this field will automatically update lines.

    I want to do the same from codeunit but getting error when I set value in this field

  • Glenn72 Profile Picture
    20 on at

    Hi Danyal.

    Did you manage to solve this issue? I am experiencing something similar, when I try to insert a job planning line record from a codeunit.

    Best Regards

    Glenn

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 3,098

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,556 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,108 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans