Team

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krishnapriya
    Senior Member
    • Aug 2017
    • 209

    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.

    Please help.
    Thanks.
  • krishnapriya
    Senior Member
    • Aug 2017
    • 209

    #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

    • tanya
      Senior Member
      • Jun 2014
      • 4308

      #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

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        did you try to do this in formula?

        Comment

        • krishnapriya
          Senior Member
          • Aug 2017
          • 209

          #5
          Can I do it with formula?

          Comment

          • krishnapriya
            Senior Member
            • Aug 2017
            • 209

            #6
            Yes but didn't work.

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

            Comment

            • krishnapriya
              Senior Member
              • Aug 2017
              • 209

              #7
              Hi,

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

              But I am really stuck with teams.

              Please help

              Comment

              • tanya
                Senior Member
                • Jun 2014
                • 4308

                #8
                create beforeSafe hook


                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

                • krishnapriya
                  Senior Member
                  • Aug 2017
                  • 209

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

                  Comment

                  Working...