[Vtigercrm-developers] Error when adding ToDo from SO/Inv/PO

John Crisp john at reetspetit.net
Mon Oct 17 08:52:16 PDT 2011


I have had an odd situation that I cannot resolve. I have tested this on
the demo server and it works but not on my installation. I can only
assume a mod somewhere has upset things but cannot see what.

When adding a ToDo to a SO/Inv/PO I was getting a stop as follows (it
worked fine from Accounts or Contacts)

Debug Error: /vtiger_521/include/database/PearDatabase.php line 789 -
Uncaught exception 'Exception' with message 'result is not an object' in
/home/e-smith/files/ibays/testbay/html/vtiger_521/include/database/PearDatabase.php:789
Stack trace:
#0
/home/e-smith/files/ibays/testbay/html/vtiger_521/include/utils/CommonUtils.php(902):
PearDatabase->query_result(false, 'name')
#1
/home/e-smith/files/ibays/testbay/html/vtiger_521/modules/Calendar/Activity.php(149):
getParentName('41945')
#2
/home/e-smith/files/ibays/testbay/html/vtiger_521/data/CRMEntity.php(72): Activity->save_module('Calendar')
#3
/home/e-smith/files/ibays/testbay/html/vtiger_521/data/CRMEntity.php(860):
CRMEntity->saveentity('Calendar', '')
#4
/home/e-smith/files/ibays/testbay/html/vtiger_521/modules/Calendar/Save.php(133):
CRMEntity->save('Calendar')
#5 /home/e-smith/files/ibays/testbay/html/vtiger_521/index.php(719):
include('/home/e-smith/f...')
#6 {main}
  thrown


It would appear that the following code in include/utils/CommonUtils.php
was causing the problem - this is from the original file and has not
been modified :

/** Fucntion to get related To name with id */
function getParentName($parent_id)
{
	global $adb;
	if ($parent_id == 0)
		return "";
	$sql="select setype from vtiger_crmentity where crmid=?";
	$result=$adb->pquery($sql,array($parent_id));
	//For now i have conditions only for accounts and contacts, if needed
can add more
	if($adb->query_result($result,'setype') == 'Accounts')
		$sql1="select accountname name from vtiger_account where accountid=?";
	else if($adb->query_result($result,'setype') == 'Contacts')
		$sql1="select concat( firstname, ' ', lastname ) name from
vtiger_contactdetails where contactid=?";
	$result1=$adb->pquery($sql1,array($parent_id));
	$asd=$adb->query_result($result1,'name');
	return $asd;
}



$sql1 gets set if the query returns for Accounts or Contacts, but NOT
for any other scenario.

My quick cheat was to add this near the top so unless it gets changed,
it returns something, but it is messy.

$sql1="select setype from vtiger_crmentity where crmid=?";

I presume there should be another 'else if' line such as :

else if ($adb->query_result($result,'setype') anything else;
	$sql1="select setype from vtiger_crmentity where crmid=?";

But I'm not sure how to write it properly !!!!

Any suggestions ?

B. Rgds
John



More information about the vtigercrm-developers mailing list