OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

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 Andrey Yatsenko 1 year, 3 months ago.

  • Creator
    Topic
  • #34575
    adriwan_kenoby
    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
    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
    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
    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
    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)

You must be logged in to reply to this topic.

You will be redirected to [title]. Would you like to continue?

Yes No