locked
Cannot get state of SalesOrder in plugin to tell whether it is fulfilled or canceled RRS feed

  • Question

  • Currently we have a SalesOrder that can be fulfilled or canceled. We have some logic that will do one thing if it is fulfilled and another when it is canceled. Currently we CAN fire the plugin after it is fulfilled or canceled but we cannot tell which state it is in. Currently we have the plugin set to fire on the Create message of the OrderClose entity and it is a preoperation. It fires but when we do a retrieve of the related salesorder its state is Active. When we check the state of the orderclose it state is always complete whether or not it is a fulfill or cancel state. We have tried setting up on the salesorder on the setstate message but that never fires. It does fire after the orderclose but it seems like the salesorder state does not change until the orderclose is completed and saved successfully. The question is how can we determine whether the salesorder is fulfilled or canceled?

    Thanks in Advance

    Wednesday, August 21, 2013 4:09 AM

Answers

  • Hi Bill,

    The status of the Order Close entity will always be complete even for a cancelled Sales Order so it is a bit of a red herring. The correct way to do this would be to register a plugin on the Pre/Post Sales Order Update plugin and check whether the statecode/statuscode is changing and then apply your logic there. It is strange that this operation goes through an Update operation and not a SetState/SetStateDynamicEntity but the whole Sales process works a bit differently to other entities.

    The Sales Order Update plugin will fire after the creation of the Order Close so you can query it or the Sales Order in your logic if needed.


    Michael Palmer
    xRMPalmer     Follow @MJFPalmer     Rockstar365

    • Marked as answer by Bill Blancett Wednesday, August 21, 2013 2:58 PM
    Wednesday, August 21, 2013 9:43 AM

All replies

  • Hi Bill,

    The status of the Order Close entity will always be complete even for a cancelled Sales Order so it is a bit of a red herring. The correct way to do this would be to register a plugin on the Pre/Post Sales Order Update plugin and check whether the statecode/statuscode is changing and then apply your logic there. It is strange that this operation goes through an Update operation and not a SetState/SetStateDynamicEntity but the whole Sales process works a bit differently to other entities.

    The Sales Order Update plugin will fire after the creation of the Order Close so you can query it or the Sales Order in your logic if needed.


    Michael Palmer
    xRMPalmer     Follow @MJFPalmer     Rockstar365

    • Marked as answer by Bill Blancett Wednesday, August 21, 2013 2:58 PM
    Wednesday, August 21, 2013 9:43 AM
  • Thanks Michael, that did the trick!

    Bill


    Thanks in Advance

    Wednesday, August 21, 2013 2:58 PM