Delivery State - change state inside action of state transition


I am doing an action on the transition from init to processing in DeliveryStateMachine. If this call fails I don’t want the state on the delivery to be processing but error instead. But even if I set the delivery state to error in the action it still comes out as processing when action complete. I know this is out of the box but how can I work around this best?

The best thing for me would be to do this action when delivery is created/getting initial state, but can’t seem to make this happen, hence I make this action on state transition init => processing since I can trigger this with related state between OrderState.Confirmed and DeliveryState.Processing. But if anyone have a tip for how to do this action when delivery enters init state I would be happy. I have tried to make an action on the DeliveryStateMachine.AddInitialState, but it won’t hit this code.

Litium version: 7.6.2

Thx in advance.

But, if your transition conditions are failing, the state will not go into “Processing”.
Would you explain the business logic behind what you are trying to do?

I’m pretty new to Litium so maybe I used the wrong terminology. But I am making an api-call in the action that occures when the delivery enters processing.
I have a feeling I don’t want this code here but in an earlier state. Maybe you can help.

The business logic is as follow. An order with a specific delivery method is placed. When this specific delivery method is selected we have to create the shipment at a third party provider with an api-call. If this call in some way fail, the delivery status should be failed and the order in attention. Else order confirmed and delivery processing.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.

So, this step should happen before a order is confirmed? - if this third party provider cannot create the delivery, does it mean the order is cancelled?
Or, the order is confirmed, and this third party delivery can be created after order confirmation?

Assuming the order is Confirmed (and it is only the shipment that need this external call)
It looks, the best place to create the shipment is, on order confirmation, just like when one is sending the order to ERP. In your case, it looks the order should create shipments in this third party system, at the same time.