OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Automatically start workflow right after create an an entity

This topic contains 4 replies, has 2 voices, and was last updated by  Andrey Yatsenko 5 years, 8 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
  • #34575

    adriwan_kenoby
    Participant

    Hi Oro Team,

    I try to start a custom workflow right after create a call entity. I am using 3.0.0-rc version

    The workflow does not perform any action for the moment

    Basically I create a Call entity and try to start workflow right after

    But I got an Exception

    The workflow is correctly loaded and stored in DB, I can start it with the UI.

    I don’t understand what is the problem.

    Some help will be appreciate.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #34577

    Andrey Yatsenko
    Moderator

    I don’t see any issues at the above code. The faster way for you to know why it’s failed will be debugging at WorkflowRegistry, you can set the breakpoint at line 53.

    First – the workflow identifier can be incorrect, or workflow was not loaded to the database or there are some caches. But if you can start it with UI – this should be ok.
    Second – some of the filters that implement \Oro\Bundle\WorkflowBundle\Model\Filter\WorkflowDefinitionFilterInterface can remove your workflow from results, but as I see at the configuration you provided – it should not, so probably it failed earlier on loading workflow from the database.

    The Task entity already has the very similar workflow, you can use it as an example:
    https://github.com/oroinc/OroCRMTaskBundle/tree/master/Resources/config/oro/workflows

    About the start from the controller – the code is valid as well. We have a similar start of the workflow at many data fixtures like this one https://github.com/oroinc/orocommerce/blob/master/src/Oro/Bundle/CheckoutBundle/Tests/Functional/DataFixtures/LoadCheckoutACLData.php#L80

    #34578

    adriwan_kenoby
    Participant

    Hi Andrey,

    At https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/WorkflowBundle/Model/WorkflowRegistry.php#L69

    $definition = $this->processDefinitionFilters(new ArrayCollection([$definition]))->first(); return null value

    At the end of this loop Line 214

    The variable $workflowDefinitions is empty.

    #34579

    adriwan_kenoby
    Participant

    Hi Andrey,

    Go in deeper I found that :

    Their is three definitionFilter
    – FeatureCheckerWorkflowRegistryFilter
    – WorkflowDefinitionScopesRegistryFilter
    – WorkflowDefinitionApplicationsRegistryFilter

    I think the problem come from https://github.com/oWorkflowDefinitionApplicationsRegistryFilter

    At Line 27 : $currentApplication = $this->currentApplicationProvider->getCurrentApplication();

    The $currentApplication is null.

    In fact the controller is called from keyyo service and I have this conf:

    This is for test purpose, i will only allow ip from keyyo after.

    The problem is that the call from keyyo to this controller is anonyme then their is no token to identify a user and then the getCurrentApplication() method return always null value.

    I don’t want to create an API method because I can’t edit Keyyo script who’s just make a GET request to a specific URL.

    Any advice to perform the action without break the security should be appreciate.

    #34580

    Andrey Yatsenko
    Moderator

    The simpler solution would be to decorate the WorkflowDefinitionApplicationsRegistryFilter to add an exception and don’t filter the phone_call workflow.

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

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

Back to top