ssossossosso

Forums

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

Open-Source CRM software 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 Hiro 2 years, 6 months ago.

  • Creator
    Topic
  • #5743
    Hiro
    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
  • #6015
    Hiro
    Hiro
    Participant

    I figured I can get the field name by:

    and refer “ExtendHelper” for the method as:

    #6029

    Alexander
    Oro Core

    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.

    #6034
    Hiro
    Hiro
    Participant

    Thank you for the follow up!

    #6035
    Hiro
    Hiro
    Participant

    The function ended up like this:

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

You must be logged in to reply to this topic.