Forums

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

This topic contains 16 replies, has 3 voices, and was last updated by Bhavesh Tailor Bhavesh Tailor 10 months, 4 weeks ago.

  • Creator
    Topic
  • #20083

    adamlundrigan
    Participant

    Here’s what I’m trying to accomplish: I have a custom entity Course with a OneToMany to another custom entity, Registration. The Course has a workflow attached which when transitioned to “Completed” asks the manager to mark each Registration as either “attended” or “absent” (using the approach outlined in the Editable Data Grid cells tutorial), which will then trigger a transition on the workflow of each individual Registration.

    I’ve run into a few roadblocks that I was hoping someone could help me out on or suggest a better way to accomplish the above:

    There doesn’t seem to be a way to add an arbitrary widget to transitionForm.html.twig, so I’ve copied it to my bundle, added my widget, then activated it by setting the page_template attribute on the “complete” transition:

    My Twig-fu is not strong so I may just be missing the right way to extend that template and add the widget to var dataBlocks?

    For now my approach on that works fine. Next step: where do I hook into the form processing so I can read the data from that oro_entity_changeset? The editable grid cells document shows a custom form handler, but WorkflowBundle’s WidgetController has no extension point in it’s form processing action (route: oro_workflow_widget_transition_form). (on further research, maybe a custom transition action is what I should be using here?)

    That brings me to the third question: After tracing the process down through the above to the transition handler this line puzzles me:

    (link). The transition handler completely short-circuits if you’re using a custom page or dialog template. When I press the “submit” button on the transition form it looks like nothing happens, I just stay on (or come back to?) the transition form because the transition handler doesn’t return the transition success response. Is there a separate handler or process for transitions which have their own custom page templates? Can I just override the transition handler and remove the short-circuit?

Viewing 15 replies - 1 through 15 (of 16 total)
  • Author
    Replies
  • #20595
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi,

    Could you please tell me what do you mean under arbitrary widget?

    If you want to override transitionFormWidget variable that you must fully override vendor/oro/platform/src/Oro/Bundle/WorkflowBundle/Resources/views/Workflow/transitionForm.html.twig

    If you want to customize form view, you can modify vendor/oro/platform/src/Oro/Bundle/WorkflowBundle/Resources/views/Widget/widget/transitionForm.html.twig

    I want to understand what do you using editable grid cells with workflow transition form? If you want to update all yours Registration entities after choosing “attended” or “absent” just write your own transition_definitions. Here is example how you can do it.

    P.S. editable grid cells is deprecated feature, better use inline editing.

    #20609

    adamlundrigan
    Participant

    Could you please tell me what do you mean under arbitrary widget?

    The transitionForm.html.twig page has one widget / section / datablock (not sure what the correct terminology is) called “General Information”. I was looking to add a second one to the page without having to copy the whole exisitng template to my own bundle just to add the necessary entry into the dataBlocks variable.

    I want to understand what do you using editable grid cells with workflow transition form? If you want to update all yours Registration entities after choosing “attended” or “absent” just write your own transition_definitions. Here is example how you can do it.

    When an admin triggers the “complete” transition on the course they must make a separate Complete/Incomplete selection per each one of those Registration records (basically a “did they attend?” question for each attendee).

    I’ve set this up by overriding the transition form template to add the datagrid which populates selections into a hidden form elememt on the transition form. It’s probably not ideal but that seems to work fine (the admin’s selections in the datagrid are sent when the transition form is submitted). The part that’s tripping me up currently is that the transition handler does nothing when you specify a custom page template. Do I need to override the transition handler too?

    P.S. editable grid cells is deprecated feature, better use inline editing.

    Thanks for the tip!

    #20611
    Mike Kudelya
    Mike Kudelya
    Oro Core

    I was looking to add a second one to the page without having to copy the whole exisitng template to my own bundle just to add the necessary entry into the dataBlocks variable.

    Unfortunately you can’t add or modify dataBlocks without copy transitionForm.html.twig.

    #20612
    Mike Kudelya
    Mike Kudelya
    Oro Core

    I have reproduced your task. I have created new custom entities:

    • NewCourse with fields name (string), status (text), registration (OneToMany)
    • NewRegistration with fields name (string), status (select)

    Added workflow src/Custom/Bundle/OroBundle/Resources/config/workflow.yml:

    Added grid src/Custom/Bundle/OroBundle/Resources/config/datagrid.yml:

    I overrided vendor/oro/platform/src/Oro/Bundle/WorkflowBundle/Controller/WorkflowController.php, transitionAction and added

    to second array parameter $this->render function

    #20613
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Added custom src/Custom/Bundle/OroBundle/Resources/views/Workflow/transitionForm.html.twig:

    #20614
    Mike Kudelya
    Mike Kudelya
    Oro Core

    What we have:

    • Custom transition template
    • We can change Course status after submit
    • Datagrid which can inline edit status of Registration entity

    I hope these tips will help you reach the goal.

    #20647

    adamlundrigan
    Participant

    Wow, thanks! I’ve read through what you created there and it’s nearly identical to what I had…glad I was on the right track at least :)

    • I use {{app.request.attributes.get(‘workflowItemId’)}} to retrieve the ID of the workflow whereas you overrode WorkflowController::transitionAction to inject it. I don’t like pulling request data directly into the template, so I’ll use your approach instead ;)
    • You use the new inline editing (which interacts with the API to do async updates, right?) whereas I used the old editable grid cells method along with an oro_entity_changeset form element, which sends the entity modifications along with the transition form submission.
    • I was missing the “redirect” action in my workflow transition definition

    One additional requirement that I didn’t outline in my original post was that the changes made in the datagrid to the Registration entity shouldn’t be applied until the Course entity is actually transitioned. Otherwise, one could start the transition, change the record statuses, then not submit the transition form and the Registration entities will have been updated but the Course will not have been transitioned. So I’ll stick with using the oro_entity_changeset method for now as it gives me protection against that. (I could have the datagrid update a “shadow” field on the Registration (transitionalStatus, or similar) and then as part of the Course transition copy the values from there into the “status” field…then, if the course isn’t transitioned the “real” status field doesn’t get updated.

    After picking up a few tips from your example and a bit more poking around myself I’ve sorted out everything that I was missing to get my approach to work. The major missing piece was needing to override Oro\Bundle\WorkflowBundle\Controller\WidgetController::transitionFormAction to process the data provided by oro_entity_changeset and store it in WorkflowItem#data:

    Is there a cleaner way to inject this logic into the transition form processing than overriding the whole controller action?

    Thanks for your help!

    #20657
    Mike Kudelya
    Mike Kudelya
    Oro Core

    which interacts with the API to do async updates, right?

    Yes, you are right.

    Is there a cleaner way to inject this logic into the transition form processing than overriding the whole controller action?

    You can create form listener, but i’m not sure that you will get access to $workflowItem

    One question, $transitionForm is creating from $workflowItem->getData(), i don’t understand, why do you select each signoff from form and again set it to $workflowItem data?

    #20672

    adamlundrigan
    Participant

    You can create form listener, but i’m not sure that you will get access to $workflowItem

    Thanks, I’ll give that a try.

    One question, $transitionForm is creating from $workflowItem->getData(), i don’t understand, why do you select each signoff from form and again set it to $workflowItem data?

    In my workflow I have a custom action “complete_course_offering” to process the admin’s selection for each Registration (stored in the oro_entity_changeset):

    That custom action just iterates over the collection of Registration records for the Course and transits each record’s workflow based on what the admin selected (Complete or Incomplete).

    When that custom action attempts to pull the data from the “signoff” element of the WorkflowItem, like this:

    It gets a NULL. The purpose of the processSignoffDataOnFormSubmit I showed in my previous post is to take the data submitted through the oro_entity_changeset element and stash it in the workflow item.

    I’ve also tried passing the signoff form data through a parameter on the action definition, eg:

    (where “signoff” is the name of the form element added under form_options -> attribute_fields section, and also a workflow attribute.)

    #20772

    adamlundrigan
    Participant

    Marking as resolved

    #24852
    Bhavesh Tailor
    Bhavesh Tailor
    Participant

    Hello ,

    I want to add Consult date into Close as Won Pop-up Window . But i am not getting how to add this field into this popup form can you please suggest me because i am using orocrm first time so i dont have idea how to add ,

    Thank You
    Bhavesh


    Bhavesh

    #24855
    Bhavesh Tailor
    Bhavesh Tailor
    Participant

    Hello,
    I got the solution for add field but need to override b2b_flow_sales_funnel/transitions.yml . I am not able to override can you please suggest how to override this transitions.yml using custom salesBundle.

    Thank you in advance ..

    Bhavesh


    Bhavesh

    #24892
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi

    Simply you should clone your ‘B2B Sales Process Flow’ workflow, activate your cloned workflow, click edit workflow, find certain transition, click edit transition, go to attributes tab and add field. Detailed information about workflow you can find in documentation. Also i wrote useful topic about overriding parts of orocrm.

    #24906
    Bhavesh Tailor
    Bhavesh Tailor
    Participant

    Hi, Mike Kudelya

    I did created clone workflow and now it’s working fine in my local server is there any way to export this and import into live server . i am doing try like already created workflow but is any any other way ?.

    Thank You .


    Bhavesh

    #24921
    Mike Kudelya
    Mike Kudelya
    Oro Core

    Hi

    You can’t import workflow on live server. You can consider these variants:

    1. create sql dump of your local database or certain workflow tables (but i think it is bad idea)
    2. customize orocrm and override transitions.yml
    3. add the same field on live server.

Viewing 15 replies - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.

ssossossosso