Mass relate / unrelate

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alasdaircr
    Active Community Member
    • Aug 2014
    • 525

    Mass relate / unrelate

    Hello there

    I've built some custom actions for contacts / leads whereby I can add or remove them from one or more target lists from their list views.

    This works fine, however I'd like to make use of the 'Select All' and where method too. In the source code there's already a dialog which supports massRelate, and so a massUnRelate should not be so tricky. However when relating / unrelating from the child entity's list view we'd need to somehow specify what the scope is (target list / etc) before opening the dialog.

    E.g list contacts by a where condition, choose Select ALL, from the action menu choose Mass Link or Mass Unlink, then in the sub menu choose the Entity Type, then Select Records dialog opens, and you can select one or more entities (also possibly using Select All and/or Where options).

    Example of how this might look:



    Do you have suggestions on how best to achieve this? We need this feature really soon, and so for now will use my Target List specific hack but it would nicer to make the process work with any relatable foreign entity.

    If anyone wants this functionality now you can use this https://github.com/alasdaircr/espocr...a5e19e317913f6 however it would be great to get this into a place as a viable pull request.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Hi

    It's better to make it the same as Mass Update. Dialog shows up and you select Link Name you want to update.

    I'm going to add this feature in future.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • alasdaircr
      Active Community Member
      • Aug 2014
      • 525

      #3
      Ok so I could get this working and submit as a PR. My main trouble was with mass unrelating, I added the extra functions to ORM/DB/Mapper.php etc but I needed to add a hack to allow a DELETE FROM when passing lists of IDs rather than passing a where clause to a DELETE FROM x JOIN. I basically did it in two calls, first SELECT the Ids, then DELETE them. It works for me, but I think with huge numbers of IDs the DELETE FROM call would fail.

      Comment


      • tothewine
        tothewine commented
        Editing a comment
        Some necro-context about a long DELETE query: every SQL batch has to fit in the batch Size Limit: 65,536 * Network Packet Size
    • yuri
      Member
      • Mar 2014
      • 8440

      #4
      I wouldn't bother about it. When do Mass Update there are very many queries are run to perform an access check. (2*n) is not a big deal in your case. Anyway it's important to check ACL for 'delete' action.
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • alasdaircr
        Active Community Member
        • Aug 2014
        • 525

        #5
        I'm checking ACL for edit action on the entity which is being unrelated from (e.g. the Target List) in the same way as the relate calls. I don't check for ACL on the contacts/leads.

        I'l push the changes up to github later on
        Last edited by alasdaircr; 11-06-2015, 02:22 PM.

        Comment

        • yuri
          Member
          • Mar 2014
          • 8440

          #6
          BTW you can use Reports to populate Target Lists.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

          • alasdaircr
            Active Community Member
            • Aug 2014
            • 525

            #7
            Yeah I know - but it would be good to have this as a built in feature for all entities

            Comment

            Working...