OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – How do I? Questions How add comment attachment on workflow transition?

This topic contains 9 replies, has 5 voices, and was last updated by  robversluis 6 years, 1 month ago.

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

  • Creator
    Topic
  • #28685

    maksold
    Participant

    I need to create comment with attachment on workflow transition. I solved problem, how to create comment on transition, but I can’t add attachment.

    Here is my code:

    When I run $ php app/console bro:workflow:definitions:load, I have error:

    What type of attribute should be comment_attachment?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Author
    Replies
  • #28686

    But you need use UploadedFile (‘file’) form type and handle upload by your self.
    If you still need help, ask me, I show you how I implement it in my project.

    #28687

    It’s not the best way, but it’s works.
    First you need custom form type for your transition that extended from WorkflowTransitionType. It will handle file upload by adding postSubmit listener.
    See my implementation https://git.io/vzYJm
    Next, use this form type for your transition by adding form_type attribute to transition

    In postSubmit convert UploadedFile to AttachmentFile or AttachmentImage according to your attribute type.

    After that you can do with attribute what you need.
    By the way, you can use setTarget method in extended entity to add relation, e.g.:

    #28688

    umatkid
    Participant

    spolischook,I have problem with it, I change to file form type, but can’t handle the uploadedFile.(got ERROR: Attribute must be an instance of “Oro\Bundle\AttachmentBundle\Entity\File”, but “Symfony\Component\HttpFoundation\File\UploadedFile” given”.
    Can you share your solutions with me and others :)
    It will be very helpful.

    #28689

    umatkid
    Participant

    spolischook, thank you for fast respond, try to use it.

    #28690

    Don’t forget to load workflow definition after changes:

    Attribute must be an instance of “Oro\Bundle\AttachmentBundle\Entity\File”, but “Symfony\Component\HttpFoundation\File\UploadedFile” given” – is about that postSubmit not work correctly. Check that you reassign attribute in postSubmit

    #28691

    umatkid
    Participant

    The option “attachmentFileAttribute” does not exist. Known options are: “action”, “attr” etc.
    What problem with this one?

    #28692

    umatkid
    Participant

    Okay, I remove this option and put name of my field to the form type. And all work, so your method work perfect :) Thank you a lot. Have a nice day :)

    #28693

    musicthebee
    Participant

    Thanks for this answer. I can add the attachment to the transition. However, When I try attach the attachment to the target entity, I get the following. Any ideas?

    #28694

    robversluis
    Participant

    @spolischook your link doesnt seems to work anymore. Can please past the code as a comment?

    See my implementation https://git.io/vzYJm

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

The forum ‘OroCRM – How do I? Questions’ is closed to new topics and replies.

Back to top