Adding assigned users from parent entity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mark
    Senior Member
    • Dec 2019
    • 143

    Adding assigned users from parent entity

    Hi,
    I wanted to consult how could I add a user from parent entity to assigned user list in the child entity. As an example would be when an email is created add assigned user of its parent as one of the assigned users for that email. The main purpose of this is to make it so the assigned users of the parent entity would be able to see those emails, with their role permissions allowing them to only see their own records.
  • emillod
    Active Community Member
    • Apr 2017
    • 1405

    #2
    You're doing this through AdvancedPack?

    Comment

    • Mark
      Senior Member
      • Dec 2019
      • 143

      #3
      I tried doing it through advanced pack, but since the relationship is parent to child it does not show the attributes of the parent entity as available when creating the workflow. And when I tried writing it in the formula it did not work. So I thought maybe it would be possible to develop such functionality using hooks?

      Comment

      • emillod
        Active Community Member
        • Apr 2017
        • 1405

        #4
        Hmmm.. it should work through AP. Check out my screenshot. Click image for larger version

Name:	2021-07-15_15-27-58_a9f5a2-Ai-154806_33349313eb43d1.png
Views:	582
Size:	68.6 KB
ID:	72512Click image for larger version

Name:	2021-07-15_15-27-58_a9f5a2-Ai-154806_33349313eb43d1.png
Views:	377
Size:	68.6 KB
ID:	72513

        Comment

        • Mark
          Senior Member
          • Dec 2019
          • 143

          #5
          I saw this option as well, but we need the assigned users from all parent entities, not only accounts. Also leads, opportunities, etc. Therefore, it is not ideal since a lead for example will not have an account associated to it yet. I now also tested manually assigning users emails, but when the role is set to 'own', they still do not see the emails. So as I understand 'own' in the email role means seeing emails, where you are either a recipient or the sender, which makes assigning users useless in this situation. Is there a way to modify the role, so it would show the emails, when you are the assigned user as well?
          Last edited by Mark; 07-19-2021, 07:14 AM.

          Comment

          • emillod
            Active Community Member
            • Apr 2017
            • 1405

            #6
            That's interesting, there actually is field assignedUser, but in most cases it's empty?
            Did you tried to assign someone to email through assignedUser(NOT assignedUsers) and test is he have access?

            Role can be adjusted, but i'm not sure is not a bug? Because if user is assigned, then he should have access.



            Comment

            • Mark
              Senior Member
              • Dec 2019
              • 143

              #7
              yeah, we tried populating both assignedUsers and singular assignedUser fields, but netiher one seemed to give access to assigned emails for that user

              Comment

              • emillod
                Active Community Member
                • Apr 2017
                • 1405

                #8
                yuri is that correct? That user assigned to email don't have access?

                Comment


                • yuri
                  yuri commented
                  Editing a comment
                  Need to add relate an email through 'users' relationship.

                • Mark
                  Mark commented
                  Editing a comment
                  where can I do that?
              • yuri
                Member
                • Mar 2014
                • 8440

                #9
                You can utilize formula to obtain an assignment user id of the parent record. It's more complex though.

                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

                • Mark
                  Senior Member
                  • Dec 2019
                  • 143

                  #10
                  How should the formula look? I tried various variants, but could not retrieve the values. Am I missing something - entity\addLinkMultipleId(assignedUsersIds, record\attribute('parentType', 'parentId', 'assignedUserId'));
                  Last edited by Mark; 07-20-2021, 12:33 PM.

                  Comment

                  • yuri
                    Member
                    • Mar 2014
                    • 8440

                    #11
                    Try:

                    Code:
                    ifThen(
                       parentId,
                       entity\addLinkMultipleId(
                           'assignedUsers',
                           record\attribute(parentType, parentId, 'assignedUserId')
                       )
                    );
                    Last edited by yuri; 07-21-2021, 01:46 PM.
                    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

                    • Mark
                      Senior Member
                      • Dec 2019
                      • 143

                      #12
                      It did not work. Could there maybe be something wrong with the record\attribute function? Because I tried retrieving just the values for parentType and parentId and that worked fine. I also tried entering the entity name and the record id manually into the record\attribute function to retrieve an attribute but it did not work. We are using currently the newest version of the system - 6.1.7

                      Comment

                      • yuri
                        Member
                        • Mar 2014
                        • 8440

                        #13
                        You also may need adding to 'users' field.

                        See attached. I can't insert CODE in the forum w/o bracking formatting. VBulleting forum is really bad.
                        Attached Files
                        Last edited by yuri; 07-22-2021, 07:36 AM.
                        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

                        • Mark
                          Senior Member
                          • Dec 2019
                          • 143

                          #14
                          Also how can I "add relate an email through 'users' relationship"? Should I just add the relationship with user entity and call it users? Or do I have to change some setting in the system files?

                          Comment

                          • Mark
                            Senior Member
                            • Dec 2019
                            • 143

                            #15
                            Alright, I think it seems to be working now. Thank you for the help!

                            Comment

                            Working...