Trouble relating custom module to Prospects/Targets

I’ve created a custom module called Target Companies with a one to many relationship to Targets (Prospects). When I edit the target, I can relate a Target Company to the target. Then when I got to view the target I just edited, I can see the related Target Company, and when I click the link it brings me to the Target Company record, as expected.

The problem is when I view the Target Company, I don’t see the the related target in the targets panel. I have to manually select the target to get it to show in the panel.

Any ideas how I can fix this?

Can you elaborate your question with some Screen Shots?

Best Regards

On my Target record, I have this relate field for Target Company:

I’m able to select the appropriate “Target Company”.

But after saving the target, when I go to view the Target Company record, in this case “Edu, Inc.”, I do not see the related target in the Targets subpanel:

Check your files permissions and owner, also do a quick repair and repair relationships

Best regards

A quick check would be to make sure that you only have the one relationship between these two modules failing that…

have a look in the sugarcrm.log file and see if there is anything there.

Ian.

The quick repair and repair relationships did not help. Which files should I check the permissions of?

What exactly do you mean by this? After I select the related “target company”, and save the the target, when I go to view the target, I can see the link to the selected target company in the detail view of the target record. If I click the link, it takes me to the correct target company record, as expected. But from the target company record, I can not see any related targets in the sub panel.

The only way to get the target to show up in the targets subpanel list on the target company record is to select the target using the button on the subpanel in the target company record (detail view).

I noticed there is a table in the database called ‘target_companies_prospects_1_c’. If I relate the target to the target company from the subpanel, a row relating the two will show up in this table. But when I relate a target company to the target and save the target record, I do not see a row added to this table.

Since I couldn’t seem to identify the root cause of this issue, I decided to add the relationship in the after_save logic hook of the Prospect module.

Here is an example of the after_save logic hook for the Prospect module:


function relate_target_company(&$bean, $event, $arguments){
		if(empty($bean->target_companies_id_c)) return;
		$targetCompany = new Target_Companies();
		$targetCompany->retrieve($bean->target_companies_id_c);
		$targetCompany->load_relationship('target_companies_prospects_1');
		$targetCompany->target_companies_prospects_1->add($bean->id);
}