Announcement

Collapse
No announcement yet.

Set calendar on dashboard correctly?

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

  • Set calendar on dashboard correctly?

    Hello all,

    I just can't get it to set the calendar properly on the dashboard.

    My problem:
    If I have entries in the calendar that I can't assign to a specific user, but just to the team, it doesn't show.
    So I always have to assign it to a user for it to show up in the calendar at all.
    So I created a placeholder user in the system and assigned this entry to him.

    I have set the month view for the team in the dashboard, selected the team in the settings. The appointments are not displayed, only when I assign it to a user. Is there a way around this, or do appointments always have to be assigned to a user?​

  • #2
    Maybe this could help?

    Comment


    • ChrisSka83
      ChrisSka83 commented
      Editing a comment
      This solution only leads to the fact that one can assign several users to an entry. But you still have to select at least 1, so that it is displayed in the calendar. Assigning to a team only does not work this way.

    • Kharg
      Kharg commented
      Editing a comment
      You can always write a formula/hook to assign all team users to assignedUsers field

  • #3
    Hi,

    The Teams field of an event (Meeting, Call, etc.) has no effect on the Calendar by design. Its purpose: access control, the ability to filter on the list view. There's no official workaround.

    Comment


    • yuri
      yuri commented
      Editing a comment
      Workaround.

      1. Create an entity, call it "MyCalendarResource". There will be the Teams field by default.
      2. Create a relationship 1-many, or many-many between Resource and your Event entity type. Enable link-multiple. Add the field to the Event layout.
      3. Write a formula script (before-save or workflow) that will take user IDs from a related resource and set it to the Users field.

  • #4
    I think that the best solution is to use AssignedUsers field and a hook to assign all the team members to the record.

    I had a similar solution but just needed it for one team, you will need to fix it according to your needs.
    PHP Code:
    <?php
    namespace Espo\Custom\Hooks\Call;

    use 
    Espo\ORM\Entity;

    class 
    AssignUsers extends \Espo\Core\Hooks\Base
    {
        public function 
    beforeSave(Entity $entity)
        {
            if (!
    $entity->isNew()) {
                return;
            }

            
    // Get the team with the name "Team A"
            
    $team $this->getEntityManager()->getRDBRepository('Team')
                ->
    where([
                    
    'name' => 'Team A'
                
    ])
                ->
    findOne();

            if (!
    $team) {
                throw new 
    Error("Could not find team with name 'Team A'");
            }

            
    // Get the active users in the team
            
    $teamUsers $this->getEntityManager()->getRDBRepository('User')
                ->
    getRelation($team'users')
                ->
    where([
                    
    'isActive' => true,
                ])
                ->
    find();

            
    // Iterate over the array of active users and get their ids
            
    $userNames = [];
            foreach (
    $teamUsers as $user) {
                
    $userNames[] = $user->get('id');
            }

            
    $entity->set('assignedUsersIds'$userNames);

        }
    }
    ?>

    Comment


    • yuri
      yuri commented
      Editing a comment
      The drawback of using the standard Teams field is that it may be not wanted behavior to assign an Event for all team users. E.g. a user has a default team, when they create a new Event, this team is prepopulated. But they wanted to create an Event only for self.

    • Kharg
      Kharg commented
      Editing a comment
      Just adding an extra bool field if true assign all team users and code it into the hook will solve this issue

  • #5
    Ok, thanks for the tips. I just wanted to make sure if this function or setting exists or I am just blind to find it.

    I have first in the settings of the field "assigned user" as default the placeholder user specified, so that one does not forget it when creating. You can then still assign it to another user, but so it appears for now in the calendar.

    But with the article of Kharg was also helped me that I had also already searched that you can assign several. Thx​

    Comment

    Working...
    X