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

Announcements

No record found.

News and Announcements icon
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;

  • Suggested answer
    JAngle Profile Picture
    159 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 740 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 531 Super User 2026 Season 2

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 310 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans