Beans for multi-word modules

Hey guys, so I dont know any otther way how to put this so - here is an example I found on youtube:

guy simply calls Accounts bean and then creates a new Bean in Contacts and then creates a relationship (the very last line in a video) like that:

$accounts -> contacts -> add($contacts);

I tried this and it works great. My problem is that when I try to do the same for Projects vs ProjectTask this particular line doesnt work. The rest works OK. So it gets a Project, creates a new ProjectTask but it doesnt link them. This is what I did:


$project = BeanFactory::getBean('Project');
$project -> retrieve_by_string_fields(array('name'=>'Create new plan for the annual audit'));
$project -> load_relationship('ProjectTask');

$projecttask = BeanFactory::newBean('ProjectTask');
$projecttask -> name = 'Demo';
$projecttask -> save();

$project -> ProjectTask -> add($projecttask);

What am I doing wrong? Why is everything working up till the last line? It worked ok with contacts so I assume its the way I type in the ProjectTask but the module is named like that… :ohmy:

Edit: this is the bug:

Fatal error: Uncaught Error: Call to a member function add() on null in C:\xampp\htdocs\crm-demo\custom\add_relationship.php:11 Stack trace: #0 C:\xampp\htdocs\crm-demo\include\MVC\Controller\SugarController.php(1020): require_once() #1 C:\xampp\htdocs\crm-demo\include\MVC\Controller\SugarController.php(468): SugarController->handleEntryPoint() #2 C:\xampp\htdocs\crm-demo\include\MVC\Controller\SugarController.php(373): SugarController->process() #3 C:\xampp\htdocs\crm-demo\include\MVC\SugarApplication.php(113): SugarController->execute() #4 C:\xampp\htdocs\crm-demo\index.php(52): SugarApplication->execute() #5 {main} thrown in C:\xampp\htdocs\crm-demo\custom\add_relationship.php on line 11

line 11 is the last line that adds relationship…

OK so I just figured it out :woohoo:

The problem was simply the big letters… So the working code is: