Newbie question: We are working on implementing D365 Finance, Commerce, and Supply-Chain Management. One of the requirements is to automatically cancel any sales line being added to a sales order if the quantity ordered is greater than the quantity available.
I've tried adding event handlers to various SalesLine table events as well as the SalesLine form data source in the SalesTable form, which checks the available quantity and sets the line status to canceled if there isn't enough available. Nothing I've tried has worked so far... either an error is thrown, or the line status does not change when it should.
Does anyone have any suggestions on the best way to accomplish this? The main question I have is which event should I subscribe to. Secondarily, is there a recommended way to modify the sales line record at the time the record is being inserted or updated, and do it in such a way that it doesn't cause problems for the SalesTable form.
Thanks in advance for any advice.