Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

How to make lowest sales price item value zero of sales order lines ?

Posted on by 204
I am building a scenario where i have 2 lines in sales order .The scenario is that we have to compare the price of both lines with each other. The item with the lower sales price price will be updated to sales price = "0" by code. Can anyone provide me guidance on this ???
For example these are the given lines the item with 36 sales price will be updated as zero.
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 288,584 Super User on at
    How to make lowest sales price item value zero of sales order lines ?
    Hi JJDunaid,
     
    Thanks for the clarification you can try some coding like the next example.
     
    public void setZeroPriceForLine(SalesTable _salesTable)
    {
        SalesLine    salesLine;
    
        ttsbegin;
    
        select firstonly forupdate salesLine
        order by salesLine.SalesPrice asc
        where salesLine.SalesId == _salesTable.SalesId;
    
        if (salesLine.RecId != 0)
        {
            salesLine.SalesPrice = 0;
            salesLine.ModifiedField(fieldNum(SalesLine, SalesPrice));
            salesLine.update();
        }
    
        ttscommit;
    }
  • JJDunaid Profile Picture
    JJDunaid 204 on at
    How to make lowest sales price item value zero of sales order lines ?
    Hi André ,
    Yes, I have a trigger point from where the functionality will work on secondly,  for instance there is no scope for quantity and Yes i need logic as i'm facing issue developing one.
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 288,584 Super User on at
    How to make lowest sales price item value zero of sales order lines ?
    Hi JJDunaid,
     
    What exact guidance do you need? Do you need help with coding to find the line with the lowest unit price? Is there any dependency on the quantity? What in case the line with unit price of 36 has a quantity of 500 where the line with price 240 has a quantity of 1?
    Do you need the logic to be executed automatically, e.g. upon confirming the order or do you have a button for the user to click? Please let us know with more details where and how you need help.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,584 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,864 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans