How to check Sync to Mail Client for Specific User on List view

In Contacts module, I set specific user on Sync to Mail client field for all contacts.

It works and all contacts are sync to specific user's outlook.

In Contacts Record view field is Sync to Mail Client field checked according to specific user.
Main problem is in List View, Sync to Mail Client field is checked or unchecked according to current user(logged in user).

Record View - checkbox is checked

  

List View - checkbox is unchecked.

checkbox should checked according to specific user.

  • Hi Pratik Harshad,

    What version of Sugar are you using? Are you testing in a vanilla instance of Sugar or are there additional configurations and/or customizations applying to the user(s) with which you are testing?

    I tested this scenario in the Fall '19 release (9.2), and the list view shows the values as expected for each individual user's sync preferences.

  • Hi Chris,

    I tested on Enterprise 9.2.0 and Professional 9.0.0.

    I successfully developed following requirement using extends Contact class.
    Requirement is Sync to Mail Client field in Contacts Module to be set for all Contacts but just for one User in the system. Not for all users.
    Record view shows correct result but List view does't.

    Contacts List - 

    Contacts Record

    Database- I set specific user_id ffc9217a-9f1a-11e9-a804-34e6d7144ede in contacts_users table. (this is not a current user or logged in user).

    Please advise. Thank you.

  • Hi Pratik, 

    I may have misunderstood your initial inquiry. I was testing the native functionality where 'Sync to Mail Client' shows the value based off the current user's setting for that record. After re-reading your post, I believe what you want is for 'Sync to Mail Client' to show as checked for all users even though it is actually only marked to sync for one user in the system.

    Can you elaborate further on what you extended from the Contact class to achieve this functionality in the record view?

  • Hi Chris,

    I have replaced current user to specific user in code.

    <?php

    require_once('modules/Contacts/Contact.php');

    class CustomContact extends Contact {

        // Specific user to add in contacts_user relationship
        public $specific_user = 'ffc9217a-9f1a-11e9-a804-34e6d7144ede';

        public function __construct() {
            parent::__construct();
            $this->specific_user_bean = BeanFactory::getBean('Users', $this->specific_user);
        }

        function fill_in_additional_detail_fields() {
            Person::fill_in_additional_detail_fields();
            if (empty($this->id))
                return;

            global $locale;

            $this->load_relationship('user_sync');

            if ($this->user_sync->_relationship->relationship_exists($this->specific_user_bean, $this)) {
                $this->sync_contact = true;
            } else {
                $this->sync_contact = false;
            }
            if (!empty($this->fetched_row)) {
                $this->fetched_row['sync_contact'] = $this->sync_contact;
            }

            /** concating this here because newly created Contacts do not have a
             * 'name' attribute constructed to pass onto related items, such as Tasks
             * Notes, etc.
             */

            $this->name = $locale->formatName($this);
        }

        function get_list_view_data($filter_fields = array()) {
            $temp_array = Person::get_list_view_data();

            if ($filter_fields && !empty($filter_fields['sync_contact'])) {
                $this->load_relationship('user_sync');
                $temp_array['SYNC_CONTACT'] = $this->user_sync->_relationship->relationship_exists($this->specific_user_bean, $this) ? 1 : 0;
            }
            $temp_array['EMAIL_AND_NAME1'] = "{$this->full_name} &lt;" . $temp_array['EMAIL1'] . "&gt;";
            return $temp_array;
        }

        /**
         *
         * @see Person::save()
         */

        public function save($check_notify = false) {
            if (!is_null($this->sync_contact)) {
                if (empty($this->fetched_row) || $this->fetched_row['sync_contact'] != $this->sync_contact) {
                    $this->load_relationship('user_sync');

                    if ($this->sync_contact) {
                        // They want to sync_contact
                        $this->user_sync->add($this->specific_user);
                    } else {
                        $this->user_sync->delete($this->id, $this->specific_user);
                    }
                }
            }
            return Person::save($check_notify);
        }

    }

    Can you advise what other approaches/solutions we can try to make it work?