vTiger - 无法从“更多信息”选项卡下的“潜在顾客模块”中选择“自定义模块”记录

I have create a custom module Chat and when am trying to select Chat records from a Leads Module under the More Information tab.

It gives me error "Warning: Invalid argument supplied for foreach() in include\utils\ListViewUtils.php on line 1280" and also its not listing any chats records but its working fine for other vtiger default module

Here is my code to set a Related List

$Vtiger_Utils_Log = true;
include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');

$accounts=Vtiger_Module::getInstance('Leads');
$accounts->setRelatedList(Vtiger_Module::getInstance('Chat'), 'Chat',Array('ADD','SELECT'));

Please help for this. Thanks in advance.

You have to Create a function as a told in Comment and your code is wrong for set relation between to module. You have to use this code.

 $module = Vtiger_Module::getInstance('Store');
 $storemodule1 = Vtiger_Module::getInstance('Calendar');
 $relationLabel = 'Activities';
 $function_name = 'get_activities';
 $module->setRelatedList( $storemodule1, $relationLabel, Array('ADD','SELECT'), $function_name );

The function which you will create replace it with 'get_activities' and i think you know which other value have to change.