Try our conversational search powered by Generative AI!

InventoryUpdate event



I have implemented the InventoryUpdated event as described here:

The events are raised as expected, however i need to know what the update to the inventory was.

If i understand the documentation correctly, it seems this information should be in the sender object, however i do not see any usefull information on the object when i debug it. Is there some casting or transformation necessary and if so how do i do that?

I use Commerce version 11.8.1


Apr 10, 2018 17:49

Try casting sender to IEnumerable<InventoryRecord>

Apr 10, 2018 20:51

I tried that, but it only becomes null, my code was this:

private void RemoteInventoryUpdated(object sender, InventoryUpdateEventArgs inventoryUpdatedEventArgs)

    var inventory = sender as IEnumerable<InventoryRecord>;

    //do stuffs


Apr 11, 2018 10:17

I'm not entirely sure but when you listen to a remote event, the sender is not "transmitted".

In future version of Commerce, the args will contain the delta changes to the inventory system. 

Apr 11, 2018 10:20

I see, do you know if there is another way to find the delta from within the event-hook?

Apr 11, 2018 10:35

Unfortunately no, it needs changes in the core, so it requires newer version from us. As always, it's good thing to keep up to date 

Apr 11, 2018 10:39

Quan - since requesting inventory via the IInventoryService in the event hook will return the "old" inventory records, does that mean that there's no way to get the updated inventory status on the same request? Any suggestion for a work around for this?

Apr 11, 2018 12:31

Technically you can get the new inventory records from database. Yes it does not sound super effective, but it works, and the records will be cached for later uses anyway 

Apr 11, 2018 13:29
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.