AnsweredAssumed Answered

How do you send invitations to users though code?

Question asked by Gaelle Fernandez on Jun 23, 2014
Latest reply on Jun 30, 2014 by Francesca Shiekh
Hello everyone!

In Sugar 7.2, I'm running an after_save logic_hook in Meetings module : when saved, the code has to search for the meeting's assigned_user, get the user that is the assigned_user's boss (by report_to_id or report_to_name) and then add the boss to the meeting.

here is my function : 

public function addToHierarchyCalendar($bean,$event,$arguments){  $bean->save();
    if ($bean->withdr_c == 1){//checkbox "with boss" is checked
     $assignedUser = new User();
     $assignedUser->retrieve($bean->assigned_user_id);
     $hierarchy_id = $assignedUser->reports_to_id;
     $boss = new User();
     $boss->retrieve($hierarchy_id);
     $bean->set_accept_status($boss,'none');
     $bean->save();
   }
}


I've found this code here : 
http://developer.sugarcrm.com/2011/03/09/howto-add-invitees-to-a-meeting-thru-code/

And found it really helpful until i get some problem :

My user (me) Gaelle Fernandez reports to gHierarchy (which exists, no doubt), but i can't see the meeting in gHierarchy's calendar....And i'm stuck in a save loop...


Could you please help me?
Thanks


Outcomes