Announcement

Collapse
No announcement yet.

Team

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Team

    Hi,
    How can I use formula set value of teams as team of assignedUser before save?

    I could do the same for user departments with the help of formula. But in that case it was one to many relationship. (user belongs to departments)
    Here teams is many to many relationship . So I am confused.
    {"alt":"Click image for larger version Name:\tteams.png Views:\t1 Size:\t6.4 KB ID:\t31466","data-align":"none","data-attachmentid":"31466","data-size":"small"}
    Please help.
    Thanks.

  • #2
    I tried in beforeSave these two ways.

    1. $entity->set('teams',$this->getUser->get('teams')) ; not working.

    and

    2. $entity->set('teamsIds', $this->getUser->get('teamsIds')) ;
    $entity->set('teamsNames', $this->getUser->get('teamsNames')) ; which gives bad server response.


    Please help.

    Comment


    • #3
      if you check apache log, you will see, that doesn't exist getUser property.... because getUser is the method and you need to use '()'
      but...
      you asked about assigned user, but write here a logged User

      Comment


      • #4
        did you try to do this in formula?

        Comment


        • #5
          Can I do it with formula?

          Comment


          • #6
            Yes but didn't work.

            I tried like this
            teamsIds=assignedUser.teamsIds
            teamsNames=assignedUser.teamsNames

            Comment


            • #7
              Hi,

              departmentsId=assignedUser.departmentsId;
              departmentsName=assignedUser.departmentsName; this formula works fine for departments.

              But I am really stuck with teams.

              Please help

              Comment


              • #8
                create beforeSafe hook
                https://www.espocrm.com/documentatio...lopment/hooks/

                Code:
                $assignedUser = $this->getEntityManager()->getEntity('User', $entity->get('assignedUserId'));
                $entity->set('teamsIds', $assignedUser->getTeamIdList());
                $entity->set('teamsNames', $assignedUser->get('teamsNames'));
                hope I typed without errors

                Comment


                • #9
                  Thank you so much tanya.. It worked great.

                  Comment

                  Working...
                  X