OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Workflow use same field in preconditions and conditions

This topic contains 10 replies, has 2 voices, and was last updated by  Mike Kudelya 6 years, 10 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #34371

    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
  • #34372

    Mike Kudelya
    Participant

    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.

    #34373

    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.

    #34374

    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 ?

    #34375

    Mike Kudelya
    Participant

    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.

    #34376

    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:


    #34377

    Dima Makaruk
    Participant

    The missing images :


    #34378

    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.

    #34379

    Mike Kudelya
    Participant

    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)

    #34380

    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)

    #34381

    Mike Kudelya
    Participant

    Hi

    Please try to use this variant.

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

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top