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 :
Microsoft Dynamics AX (Archived)

Sales Line Cost Price/Line Amount not updating when creating sales line using code(x++) AX 2009

(0) ShareShare
ReportReport
Posted on by

Hi All,

I am able to create sales order header and sales lines through code in AX 2009 AOT job. But Sales Line price or amount not updating for items. 

Here is my sample code to create sales lines:-

static void CreateSalesLine(Args _args)
{
SalesTable salesTable;
SalesLine salesLine;
;
ttsbegin;
salesTable = SalesTable::find('sales order number');
salesLine.clear();
salesLine.SalesId=salesTable.SalesId;
salesLine.ItemId = "itemId";
salesLine.createLine(NoYes::Yes,
NoYes::Yes,
NoYes::Yes,
NoYes::Yes,
NoYes::Yes,
NoYes::Yes);
ttscommit;

}


Any help would be really appreciated.

Thanks

Arun Kumar

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,231 Super User 2025 Season 2 on at

    Hi Arun,

    You need to call the method salesLine.itemIdChanged() after you have filled the ItemId field.

  • Community Member Profile Picture
    on at

    Hi Andre,

    I've tried with salesLine.itemIdChanged() but Price or Amount still showing 0.00 in Sales Order Items form view.

    Any idea what I am missing?

  • André Arnaud de Calavon Profile Picture
    301,231 Super User 2025 Season 2 on at

    Hi AKumar,

    Do you have any trade agreements setup for this item? When you manually create the line in the sales order form, are the values filled correctly? Did you also try to set a quantity in the code to create the line?

  • Community Member Profile Picture
    on at

    I've created sales lines using sales order form and still values are not filled for Price and Amount. Also I've tried with SalesQty filled but no success.

  • André Arnaud de Calavon Profile Picture
    301,231 Super User 2025 Season 2 on at

    In that case you are probably missing trade agreements or a price setup on the item form. It's not due to coding.

  • Community Member Profile Picture
    on at

    Thanks for your suggestions.

    I will confirm that.

  • Community Member Profile Picture
    on at

    I've confirmed and there are no trade agreements setup on the items.

    Can you please provide me steps to achieve this. How can I update the Price fields using code?

    Thanks in advance.

  • André Arnaud de Calavon Profile Picture
    301,231 Super User 2025 Season 2 on at

    Try to setup some prices and see if the code suggestion "salesLine.itemIdChanged()" will work then.

  • Mea_ Profile Picture
    60,284 on at

    Why you don't want to set price and qty in your code ?

    salesLine.PriceUnit = 1050.00;

    salesLine.SalesQty = 10;

  • Community Member Profile Picture
    on at

    I've checked and prices are already setup for item under Inventory Management- > Item Details -> Price.

    When sales line created by code Unit Price field is populating for Item but not Price or Amount field on Sales Order 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

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans