Hi to all, fast question, i have like 20 meetings and i have to reassign to an user, but if i do, still doesn’t appear on his calendar. I’ve read i have to update the attendees but there is a way to “mass update”(except create script on sql) instead of open every single meeting and update this?
I’m sorry, I don’t think there is a way to do that.
Instead of SQL, probably a logic hook could be easier. Whenever a meeting assignment is changed, you can add the new user as an attendee, if he isn’t already there.
This way you could still use the Mass Update to assign the meetings from the UI, and it would solve your problem inside the logic hook called for each record.
Ok so i can use an aftersave logic hook. But if the mass update is already done, i have to edit the sql. Thanks for the info
Sorry for the dumb question but, there is a way to avoid a loop save in a logic hook aftersave? everytime i have to create a field called “already_saved_c” and skip if == 1. There is a better way?
Well, if someone needs, here the code of the logic hook to create an attendee with the assigned user id
if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
class updateAttendees {
function updateAttendees ($bean, $event, $argument){
$bean_meetings = BeanFactory::getBean('Meetings');
$meeting = $bean_meetings->retrieve_by_string_fields(array('id'=>$bean->id,'deleted'=>'0'));
$meeting->load_relationship('users');
$exist = 0;
foreach ($meeting->users->getBeans() as $users){
if($users->user_id == $meeting->assigned_user_id || empty($users->user_id))
$exist = 1;
}
if(!$exist){
$meeting->users->add($bean->assigned_user_id);
$meeting->save();
}
}
}
Thanks for sharing the code!
About your question earlier - I think your technique with an extra field is the standard approach.
actually in this case with the check of the $exist i can avoid the loop way of the after_save method.
Btw i think could be a default logick hook for the activities for the newer version. or not?
If it goes into the main code, it’s better not to use a logic hook, which is for code extensions. But there are some exceptions to this rule…
I leave the code here, if it’s usefull for someone i’ve done my part