web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Glenn72 Profile Picture
    20 on at
    RE: Getting error while setting value in Inv. Discount Amount Excl. Tax (USD) of sales order

    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

  • Danyal Profile Picture
    259 on at
    RE: Getting error while setting value in Inv. Discount Amount Excl. Tax (USD) of sales order

    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

  • Suggested answer
    JAngle Profile Picture
    115 on at
    RE: Getting error while setting value in Inv. Discount Amount Excl. Tax (USD) of sales order

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

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sumit Singh Profile Picture

Sumit Singh 3,055

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 2,682 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 2,209 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans