OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – How do I? Questions Get the dynamic field name in Attachment Table for Entity

This topic contains 4 replies, has 2 voices, and was last updated by  Hiro 9 years, 7 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
  • #28151

    Hiro
    Participant

    I have noticed Attachment data is left out when deleting Entity record using Attachment feature.

    So I started creating this helper function so that I can just call it from deleteAction() in REST API Controller Class:

    One thing I cannot figure is about how we can know the extended field name in code.

    Please let me know if there is already the deletion method somewhere.

    I have found deleteAction() in Oro\Bundle\AttachmentBundle\Controller\Api\Rest, but the parameter is the Id for the attachment, not Entity Id so.

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

    Hiro
    Participant

    I figured I can get the field name by:

    and refer “ExtendHelper” for the method as:

    #28153

    Alexander
    Moderator

    Hi Hiro,

    Actually you are right, you should use ExtendHelper::buildAssociationName to get field name for fields of “attachment” type.
    And as an example you can look into src/Oro/Bundle/AttachmentBundle/Migration/Extension/AttachmentExtension.php, method addAttachmentAssociation. Here is realization of adding attachment field via migration, and ExtendHelper used to build association name.

    #28154

    Hiro
    Participant

    Thank you for the follow up!

    #28155

    Hiro
    Participant

    The function ended up like this:

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

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

Back to top