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...
Answered

Event Subscriber Item Trigger behavior unexpected with "Qty. on Sales Order"

(0) ShareShare
ReportReport
Posted on by 32

I have created an event subscribers on the Item table and another on the   'Qty. on Sales Order'    field of the Item table. See below snippets: 

[EventSubscriber(ObjectType::Table, Database::Item, 'OnAfterValidateEvent', 'Qty. on Sales Order', false, false)]
*trivial function code here*
[EventSubscriber(ObjectType::Table, Database::Item, 'OnAfterModifyEvent', '', false, false)]
*trivial function code here*

My issue is when I create a new sales or purchase line, my Item event subscribers are not fired. The reason I believe they should be is because Qty. on Sales Order is updated on the item every time I create a new sales line with that item. I have confirmed this by checking the data before and after creating a sales line. 

Does business central only fire event subscribers for manual edits such as changing the description or display name of an item? or a better question,

Does business central fire event subscribers for readonly value changes such as "Qty. on Sales Order" ?

*Note: The event subscriber works well for everything I need except for when "Qty. on Sales Order" and "Qty. on Purch Order" change. For example when I update the item header it will trigger the item table subscriber. I need to know when those two fields on an item change.

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    Hi JaredT ,

    Qty. on Sales Order and Qty. on Purch. Order field are Flowfields which automatically calculates when you put this item on Sales and Purchase line respectively, and flowFields does not fire any Validate event, and that is the reason why your OnafterValidateEvent fire.

    But your event [EventSubscriber(ObjectType::Table, Database::Item, 'OnAfterModifyEvent', '', false, false)] should run perfectly.

    Thanks.

  • JaredT Profile Picture
    32 on at

    Hi Nitin, thank you for getting back. I have added Message() calls at the very beginning of my Item modify trigger.

    I can confirm the trigger message works when changing the item header description OnAfterModifyEvent.

    However when changing quantity numbers in a sales line it does not trigger the item table OnAfterModifyEvent.

    Are there any other things I can check for or ways to troubleshoot this?

  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    Hi JaredT ,

    Not sure what you are looking for, but If you are modifying or changing the qty. on Sales or Purchase line, it will never calls the  trigger of any Item, instead if you want to check how much the qty. is on Item."Qty. on Sales Order". you can write below code.

    OnAfterValidateEvent "Quantity" on Sales Line.

    if Item.get(SalesLine."No.") then

    begin

     item.calcfields("Qty. on Sales Order");

     Message('%1',Item."Qty. on Sales Order");

    end;

    You can replace the above message function with your custom statements according to your requirement.

  • Verified answer
    YUN ZHU Profile Picture
    95,716 Super User 2025 Season 2 on at

    Hi, This is because the field 'Qty. on Sales Order' you subscribe to is a FlowField. As you might know, the value of FlowField do not actually exist in the table, but are recalculated when the page is opened. So OnAfterValidateEvent has no effect on it.
    I think you need to change your solution. As Nitin mentioned, you should add your all codes to the events on sales lines.

    pastedimage1654220205752v1.png

    Hope this helps as well.

    Thanks.

    ZHU

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 2,664

#2
YUN ZHU Profile Picture

YUN ZHU 960 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans