OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – How do I? Questions How do I associate a custom activity to another entity?

This topic contains 4 replies, has 3 voices, and was last updated by  nnenasheva 8 years, 9 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
  • #28473

    cflynn
    Participant

    I’m building a custom activity that I want to be able to associate to leads (very similar to calls, emails, tasks).

    I’ve been able to create the custom activity entity in a custom bundle I’m creating. So far I can create, edit, delete and show the new activity in the navigation.

    I have not been able to figure out how to associate the new custom activity to the Lead Entity.

    In the documentation on Github https://github.com/orocrm/platform/tree/master/src/Oro/Bundle/ActivityBundle the bundle states

    The OroActivityBundle provide ability to assign activities (calls, emails, tasks) to other entities. The system administrator can manage this functionality on System / Entities / Entity Management page.

    I’ve tried creating a many to many relationship to the Lead Entity but the new activity does not show up in the Leads “More Actions” dropdown.

    I also need to submit custom activities via the REST api and associate them to a lead. I have not seen any reference to being able to do this in the rest docs. Is there a way to do this?

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

    cflynn
    Participant

    By adding an association field to my custom activities api-form-type and an api-form-handler with a handleAssociations function much like the OroCRMCallBundle:Form/Handler/CallApiHandler handleAssociations functionality I was able to resolve submitting the custom activity association via the API.

    However, When I submit the custom activity I get the error “The association with \”OroCRM\\Bundle\\SalesBundle\\Entity\\Lead\” entity was not configured”.

    I traced the exception to the extended entity that was created

    /**
    * Associates the given entity with this entity
    *
    * @param object $target Any configurable entity that can be associated with this type of entity
    * @return object This object
    */
    public function addActivityTarget($target)
    {
    $className = \Doctrine\Common\Util\ClassUtils::getClass($target);
    throw new \RuntimeException(sprintf('The association with "%s" entity was not configured.', $className));
    }

    Do I need to overwrite these functions in my custom activity entity or is there something I’m missing when using the “System / Entities / Entity Management page” that the activity bundle tells you to use?

    #28475

    cflynn
    Participant

    Found the solution in https://github.com/orocrm/platform/blob/master/src/Oro/Bundle/EntityExtendBundle/Resources/doc/associations.md

    The Activity Association field name needed ExtendHelper::buildAssociationName as the field name for the many to many relationship.

    The documentation is not very clear when referring to “The system administrator can manage this functionality on System / Entities / Entity Management page.”. This would mean the system administrator would know how to build the correct association name since the entity management page does not generate an association field name.

    #28476

    Artem Liubeznyi
    Spectator

    Hi Chris,

    Thanks for pointing this out, we will adjust the documentation to make it more clear.

    #28477

    nnenasheva
    Participant

    If custom activity is created in the same manner is default activities, you can also assign it in UI.

    It will appear in the entity create/edit form and can be assigned to an entity in the same manner as any other activity.

    Please see “Communication and collaboration” section in the entity management doc for more details (http://oroinc.com/orocrm/doc/current/user-guide/entities)

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