What are the Slack Archives?

Itโ€™s a history of our time together in the Slack Community! Thereโ€™s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you wonโ€™t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi guys, currently working on OMS and statemachine. One thing that bugs me: Suppose I have the follo

michael.schmetter
michael.schmetter Posts: 119 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

Hi guys,
currently working on OMS and statemachine.
One thing that bugs me:
Suppose I have the following state machine:

<?xml version="1.0"?>
<statemachine
xmlns="spryker:oms-01"
xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>"
xsi:schemaLocation="spryker:oms-01 <http://static.spryker.com/oms-01.xsd>">
<!-- Used as example XML for OMS implementation -->

    <process name="Demo01" main="true">
        <states>
            <state name="new" />
            <state name="unauthorized" />
            <state name="paid" />
        </states>

        <transitions>
            <transition condition="Demo/IsAuthorized" happy="true">
                <source>new</source>
                <target>paid</target>
                <event>pay</event>
            </transition>
            <transition><!-- else -->
                <source>new</source>
                <target>new</target>
            </transition>
        </transitions>

        <events>
            <event name="pay" onEnter="true" command="Demo/SendNotification" />
        </events>
    </process>
</statemachine>

I can't get it working, that the condition is checked at oms:check-condition .
Here statemachine is picking up only conditions. that have no event:
https://github.com/spryker/oms/blob/d6cc889a6e846d08e5a423d36d44e41b38cd51ce/src/S[โ€ฆ]pryker/Zed/Oms/Business/OrderStateMachine/OrderStateMachine.php

What I would like to achive is that, that a transition is triggered if condition Demo/IsAuthorized is met, and then the command Demo/SendNotification is executed.
Did I get the concept of commands and conditions wrong, that they are not working together or did I just configure something wrong? ๐Ÿค”

Comments

  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    The else transition is not needed. The transition will only happen when the condition is met

  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    then, I never saw a transition with both command and condition, not sure if that's possible

  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    if not, try to add and intermediate state and transition to separate that

  • michael.schmetter
    michael.schmetter Posts: 119 ๐Ÿง‘๐Ÿปโ€๐Ÿš€ - Cadet

    Hi @U01A5ARAXP0,
    thanks for your response!
    I now are doing it with a separate step, which I was trying to avoid. but now it works.