Problem adding User Invitees when creating a meeting

I am trying to programmatically invite additional users to a meeting when creating a meeting. However its not working.

Here is the code I use to create a meeting for a Case. I added the user_invitees line thinking that might be all that is needed. This is a comma separated list of user ids I want invited when the meeting is created.

            $meeting = BeanFactory::newBean('Meetings');
            $meeting->name = $bean->name;
            $meeting->date_start = $dateTime;
            $meeting->duration_minutes = (intval($bean->schedule_duration_c) / 60);
            $meeting->assigned_user_id = $bean->assigned_user_id;
            $meeting->assigned_user_name = $bean->assigned_user_name;
            $meeting->description = $bean->name . " - Case assigned to: " . $bean->assigned_user_name;
            $meeting->status = "Planned";
            $meeting->contact_id = $bean->contact_id;
            $meeting->parent_id = $bean->id;
            $meeting->parent_type = 'Cases';
            $meeting->update_vcal  = false;
            $meeting->user_invitees = "619a19b0-4d61-0a33-45fb-633de26eba7a,9e8991a2-b8df-fe5f-2fb0-6304fe418a2d,489560de-6cc7-301c-d3f3-635179155ea5";
            $meeting->save();

Is there something else needed or should I just use a SQL statment:

INSERT INTO meetings_users (id, user_id,meeting_id,accept_status, date_modified) 
VALUES ($id, $userid, $meetingid, 'accept', date())

Tony

Ensure you’re filling all the required fields. In your case it seems to be missing the end date.

@pgr

Even setting the end date does not add the user_invitees.
Do you see any meeting fields that I am missing?

Tony

Sorry, don’t know what else to check. I would just use a debugger, step into that save function and see where it’s getting into trouble.

@tkoehn

I think that you shouldn’t use variable:

 $meeting->user_invitees

It doesn’t work. You need to add relationship after save the meeting. Try like this:

$user_invitees = array
(
    "619a19b0-4d61-0a33-45fb-633de26eba7a",
    "9e8991a2-b8df-fe5f-2fb0-6304fe418a2d",
    "489560de-6cc7-301c-d3f3-635179155ea5"
);
$meeting->load_relationship('users');
foreach ($user_invitees as $user_id) 
{
    $meeting->users->add($user_id);
}

If you want sending ‘invitation’ or doing ‘accept’ you need add a code.

I don’t recommend to using this:

@pgr

For information only.
Objects Meeting and Call use function ‘handleSave’ form files ‘modules/Meetings/MeetingFormBase.php’ or ‘modules/Meetings/CallFormBase.php’ for save.

1 Like

Thank you very much. This worked as you mentioned.

I see now that you must save the meeting first and then add users to an existing meeting.

Tony