ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 10 replies, has 2 voices, and was last updated by Mike Kudelya Mike Kudelya 4 months, 1 week ago.

  • Creator
    Topic
  • #34254

    Dima Makaruk
    Participant

    I have following example workflow:

    The transition has a form where the product.status is set.
    It’s not possible to execute the transition after setting the product.status as it’s not allowed.

    Are the precoditions being also checked when executing a transition ?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Author
    Replies
  • #34261
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi

    As i understood you want to show a popup when entity product->status field is empty and set form field constraint to avoid enter empty values. If yes, please add the following code to your transition:

    Here is an example.

    #34262

    Dima Makaruk
    Participant

    In my case the popup works and saves the value.

    But the transition is not executed because after product save the precodition is not valid anymore, because the product has the status.

    Part of code from Oro\Bundle\WorkflowBundle\Model\Transition

    The transition should only be possible if the value is empty. The form should be shown only if product status has no value.

    Here is a part from the docs:

    There are two types of conditions – preconditions and actually transit conditions. Preconditions is used to check whether transition should be allowed to start, and actual conditions used to check whether transition can be done. Good example of usage is transition forms: preconditions are restrictions to show button that open transition form dialog, and actual transitions are used to validate form content after submitting.

    So i supposed the preconditions are being only validated to check if a transition is valid.

    #34268

    Dima Makaruk
    Participant

    As it’s written in the docs, the preconditions are used to check if the transition should be allowed to start. Why are the precondition also checked when executing the transition,after it was already started ?

    #34310
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Why are the precondition also checked when executing the transition, after it was already started ?

    I think it has been done to avoid manually sending the http request to the server (without pressing the button).

    Your transition is not executed because when you execute the ‘conditions’ node, $product.status is still empty because the ‘conditions’ node is checked before saving.

    $product.status – checking the product entity status field.
    $status – checking the form status field.

    Try to check your transition using the following approach:

    Do not forget to add a status attribute.

    #34311

    Dima Makaruk
    Participant

    Hi Mike,

    as i already described before, the preCondition is not valid when executing the transition. The condition is ok, because the transition object is already saved , when the transition is executed.

    Here some debugging info:


    #34313

    Dima Makaruk
    Participant

    The missing images :


    #34331

    Dima Makaruk
    Participant

    Hi Mike,

    the case you’ve described, also won’t work. Because of the precondition. In isAllowed method of the Transition model preconditions are also checked , before finishing the transition.

    #34380
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi

    Can you describe start values of your fields, which participate in the work, detailed use case, how should work your fields? (popup fields types, when the step button/popup must be shown, what condition must be executed when you click to Save button in your popup)

    #34381

    Dima Makaruk
    Participant

    Hi

    it should work as follows:

    – the transition button should be enabled if $product->status is null (precondition)
    – the popup form has only one dropdown with the status values
    – after clicking the ‘save’ in popup product status is saved
    – executing transition if $product->status is not null (condition)

    #34394
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi

    Please try to use this variant.

Viewing 10 replies - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.