Notify on Assignment - Multiple/Infinite Emails

First the Problem: My users are getting emailed every time a project is saved that the project has been assigned to them, not just the first time.

A Bit of Background: I recently upgraded from 7.3.x to 7.7.3, at the same time I moved servers

Has anyone had this issue before, or know what could be causing it?


OK, I have figured out why this is happening, but not how to fix it. In 7.7.3, edit view in Projects has a resource list at the bottom, and the creator is automatically added.

So, by default, in a clean install of 7.7.3, the following if statement evaluates as FALSE because !isset($_POST[‘user_invitees’]) evaluates as FALSE (note the not).

From /modules/Project/Project.php (note, this section of code was not in the version I upgraded from 7.3.x):

	if( (isset($_POST['isSaveFromDetailView']) && $_POST['isSaveFromDetailView'] == 'true') ||
			(isset($_POST['is_ajax_call']) && !empty($_POST['is_ajax_call']) && !empty($focus->id) ||
			(isset($_POST['return_action']) && $_POST['return_action'] == 'SubPanelViewer') && !empty($focus->id))||
			 !isset($_POST['user_invitees']) // we need to check that user_invitees exists before processing, it is ok to be empty
			$GLOBALS['log']->debug('Save Called from Project.php, Save forced true.');
			parent::save(true) ; //$focus->save(true);
			$return_id = $focus->id;

You’ll notice that the parent::save(true); command forces $check_notify arguement to true, which is tells the SugarBean that the assigned_to has changed, and that we should notify them.

_sendNotification function within SugarBean.php

if ($check_notify || (isset($this->notify_inworkflow) && $this->notify_inworkflow == true) // cn: bug 5795 - no invites sent to Contacts, and also bug 25995, in workflow, it will set the notify_on_save=true.
            && !$this->isOwner($this->created_by)

So I either need to figure out how to get that little widget (Resources) in my Project Edit View (which by the way, is not in the editviewdefs.php) or I need to change some code in Project.php… but that seems like a band-aid… that will likely fall off during the next upgrade.


I think I found the problem, and a possible solution.

Issue #2164