Calling Developers!
We are reenergizing our code contribution process! Learn More

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

Options
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
    Options

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

  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 🧑🏻‍🚀 - Cadet
    Options

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

  • U01A5ARAXP0
    U01A5ARAXP0 Posts: 119 🧑🏻‍🚀 - Cadet
    Options

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

  • michael.schmetter
    michael.schmetter Posts: 119 🧑🏻‍🚀 - Cadet
    Options

    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.