Meeting Not showing up on Calendar

I am using Case Logic hook to create a meeting when the user clicks on a custom checkbox. The meeting event is created but never shows up on the calendar. After some searching around I noticed that there is not a record for the meeting in the meetings_users table. Manually adding a record in this table results in the meeting showing up on the calendar.

Taken from the populateSeedData.php, here is what I am using to create the meeting.

$meeting = BeanFactory::newBean('Meetings');
$meeting->name = $bean->name;
$meeting->date_start = create_date() . ' ' . create_time();
$meeting->duration_hours = 1;
$meeting->duration_minutes = 0;
$meeting->assigned_user_id = $bean->assigned_user_id;
$meeting->assigned_user_name = $bean->assigned_user_name;
$meeting->description = $bean->name;
$meeting->status = "Planned";
$meeting->contact_id = $bean->contact_id;
$meeting->parent_id = $bean->id;
$meeting->parent_type = 'Cases';
// dont update vcal
$meeting->update_vcal  = false;
$meeting->save();
$meeting->set_accept_status($meeting->assigned_user_id, 'accept');

$bean->meetingid_c = $meeting->id;

I even replaced the code

$meeting->set_accept_status($meeting->assigned_user_id, 'accept');

with:

$focus = BeanFactory::newBean('Meetings');
$focus->id = $meeting->id;
$test = $focus->set_accept_status($meeting->assigned_user_id, 'accept');

I wanted to see what I might be doing wrong or if there were any other options before I add a statement to just add the record manually.

While I am at it can someone tell me what vcal is?

Tony

vcal is the format for Calendar publishing. I am not sure what it means in this context, though.

Based on what you wrote, I would say you just need to create a relationship between the user and the meeting. Have a look at the part about relationships here

I found my problem. The set_accept_status uses an object not a user id as I was thinking. Once I reviewed the populateSeedData one more time I saw what I did wrong. I also realized that my date was creating a random date. Here is my working code.

$dateTime = date("Y-m-d H:s:i");
$user = BeanFactory::newBean('Users');  // Needed to assign user to meeting
// Create a meeting
$meeting = BeanFactory::newBean('Meetings');
$meeting->name = $bean->name;
$meeting->date_start = $dateTime;
$meeting->duration_hours = 1;
$meeting->duration_minutes = 0;
$meeting->assigned_user_id = $bean->assigned_user_id;
$meeting->assigned_user_name = $bean->assigned_user_name;
$meeting->description = $bean->name;
$meeting->status = "Planned";
$meeting->contact_id = $bean->contact_id;
$meeting->parent_id = $bean->id;
$meeting->parent_type = 'Cases';
// dont update vcal
$meeting->update_vcal  = false;
$meeting->save();
$user->id = $bean->assigned_user_id;            
$meeting->set_accept_status($user, 'accept');
$bean->meetingid_c = $meeting->id;
1 Like