<span style="font-family: courier new,monospace;">Hi,</span><br><br><span style="font-family: courier new,monospace;">$record = $client->doCreate($module,</span><span style="font-family: courier new,monospace;"><br> array(</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">
'account_no'=>"$societe",</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
'phone'=>"$telephone2",</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
'fax'=>"$fax",</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
...</span><span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">);</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace; background-color: rgb(255, 255, 153);">if($record === false) {</span><br style="font-family: courier new,monospace; background-color: rgb(255, 255, 153);">
<span style="font-family: courier new,monospace; background-color: rgb(255, 255, 153);"> echo "Creation Error! " . $client->lastError();</span><br style="background-color: rgb(255, 255, 153);"><div style="direction: ltr; font-family: courier new,monospace;">
<span style="background-color: rgb(255, 255, 153);">} else {</span><br style="background-color: rgb(255, 255, 153);"><span style="font-family: courier new,monospace; background-color: rgb(255, 255, 153);"> $accountid = $client->getRecordId($record['id']);<br>
</span><span style="background-color: rgb(255, 255, 153);">echo "new account id : $accountid <br />";</span><br style="background-color: rgb(255, 255, 153);"><span style="background-color: rgb(255, 255, 153);">}<br>
</span><span><br><span style="font-weight: bold;">accountname </span>is mandatory field which is not set in the parameters. <br>This could be a reason for failure. The if condition is fine but else condition (on error) is not captured. Highlighted is piece of code that could help in debugging.<br>
</span><span style="background-color: rgb(255, 255, 153);"><br></span><span>Regards,<br>Prasad<br>vtiger Team<br></span><br></div><div><span class="gmail_quote">On 9/24/09, <b class="gmail_sendername">Fusioncore</b> <<a href="mailto:ml@arceva.fr">ml@arceva.fr</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi<br> I have create a plugin for my website who create account and contact in<br> vtiger when a customer register on the website.<br> For this purpose, I use vtwsclib 1.2 with php doCreate method<br> after the script creation, I test it and it work well with contact<br>
creation but for the account, nothing was add on vtiger.<br> The method LastError was on error when I use it<br> <br> I paste my code if anyone have an idea of the error. See the bug part of<br> the file around the //bug<br>
The include files access.php contain only url, login and password and<br> the functions.php contain functions addPortalAccess and addDate who work<br> perfectly<br> <br> Thanks,<br> Bruno<br> French-vtiger Manager<br> <br>
<br> <br> <br> <?php<br> <br> include_once('/var/www/site/access.php'); //logins site & CRM<br> include_once('vtwsclib/Vtiger/WSClient.php'); //Librairie SOAP CRM<br> include_once('/var/www/site/www/sync/functions.php');<br>
<br> //Connexion base de données<br> mysql_connect($sitedbhost,$sitedbuser,$sitedbpassword,$sitedb);<br> mysql_select_db($sitedb);<br> <br> //Vérification si il y a des users a synchroniser<br> $verif = mysql_query("SELECT NULLIF(1, (SELECT MIN(sync_crm) FROM users))");<br>
$verif1 = mysql_result($verif, 0, 0);<br> //echo"$verif1";<br> if ($verif1 == "")<br> echo "Nothing to sync";<br> else<br> {<br> //Comptage du nombre d'utilisateurs à synchroniser<br>
$test_needed = mysql_query("SELECT COUNT(0) FROM jos_users WHERE<br> sync_crm=0 GROUP BY sync_crm");<br> $sync_needed = mysql_result($test_needed, 0, 0);<br> //*echo "number of non sync user : $sync_needed";<br>
while ($sync_needed >= 1) //Boucle tant qu'on a des users a<br> synchroniser<br> {<br> $result = mysql_query("SELECT id FROM users WHERE sync_crm=0");<br> $current_user_sync = mysql_result($result, 0, 0);<br>
//*echo "<br />Id of current sync user :<br> $current_user_sync<br />";<br> <br> //Extraction des infos de l'utilisateur<br> <br> $user_extend = mysql_query("SELECT * FROM<br>
juser_extended_data WHERE user_id='$current_user_sync'");<br> $ident = mysql_query("SELECT * FROM users WHERE<br> id='$current_user_sync'");<br> $identity = mysql_result($ident, 0, name);<br>
$name = explode("\n", $identity);<br> // Champs pour le compte<br> $prenom = $name[0];<br> $nom = $name[1];<br> $email = mysql_result($ident, 0, email);<br>
$telephone1 = mysql_result($user_extend,2 ,fvalue);<br> //Champs pour le contact<br> $societe = mysql_result($user_extend,1 ,fvalue);<br> $telephone2 = mysql_result($user_extend,3 ,fvalue);<br>
$fax = mysql_result($user_extend,4 ,fvalue);<br> $siret = mysql_result($user_extend,5 ,fvalue);<br> $codeape = mysql_result($user_extend,6 ,fvalue);<br> $secteur = mysql_result($user_extend,7 ,fvalue);<br>
$poste = mysql_result($user_extend,8 ,fvalue);<br> $nbsalaries = mysql_result($user_extend,9 ,fvalue);<br> $site = mysql_result($user_extend,10 ,fvalue);<br> $adresse = mysql_result($user_extend,11 ,fvalue);<br>
$BP = mysql_result($user_extend,12 ,fvalue);<br> $CP = mysql_result($user_extend,13 ,fvalue);<br> $ville = mysql_result($user_extend,14 ,fvalue);<br> $pays = mysql_result($user_extend,15 ,fvalue);<br>
$username = mysql_result($ident ,0, username);<br> $passwd = mysql_result($ident, 0, password);<br> <br> //Fin d'extration des infos de l'utilisateur<br> //bug start<br> //Connexion au CRM<br>
$client = new Vtiger_WSClient($crm_url);<br> <br> $login = $client->doLogin($crm_username, $crm_accesskey);<br> if(!$login)<br> echo 'Login Failed';<br> else<br>
{<br> /**/echo "Login Successful<br />";<br> $module = 'Accounts';<br> $module2 = 'Contacts';<br> <br> $record = $client->doCreate($module,<br>
array(<br> 'account_no'=>"$societe",<br> 'phone'=>"$telephone2",<br> 'fax'=>"$fax",<br>
'siccode'=>"$codeape",<br> 'industry'=>"$secteur",<br> 'employees'=>"$nbsalaries",<br> 'website'=>"$site",<br>
'ship_street'=>"$adresse",<br> 'ship_pobox'=>"$BP",<br> 'ship_code'=>"$CP",<br> 'ship_city'=>"$ville",<br>
'ship_country'=>"$pays",<br> 'bill_street'=>"$adresse",<br> 'bill_pobox'=>"$BP",<br> 'bill_code'=>"$CP",<br>
'bill_city'=>"$ville",<br> 'bill_country'=>"$pays",<br> )<br> );<br> <br> if($record) {<br>
$accountid = $client->getRecordId($record['id']);<br> }<br> echo "new account id : $accountid <br />";<br> <br> //bug end<br> <br> $record = $client->doCreate($module2,<br>
array(<br> 'firstname'=>"$prenom",<br> 'lastname'=>"$nom",<br> 'email'=>"$email",<br>
'phone'=>"$telephone1",<br> 'title'=>"$poste",<br> 'accountid'=>"$accountid",<br> )<br>
);<br> <br> if($record) {<br> $contactid = $client->getRecordId($record['id']);<br> }<br> echo "new contact id : $contactid <br />";<br>
<br> <br> addPortalAccess($crmdbhost,$crmdb,$crmdbuser,$crmdbpasswd,$contactid,$username,$passwd);<br> <br> addDate($crmdbhost,$crmdb,$crmdbuser,$crmdbpasswd,$contactid);<br> <br> mysql_query("UPDATE users SET sync_crm=1 WHERE<br>
id=$current_user_sync");<br> <br> $sync_needed--;<br> }<br> }<br> }<br> ?><br> _______________________________________________<br> Reach hundreds of potential candidates - <a href="http://jobs.vtiger.com">http://jobs.vtiger.com</a><br>
</blockquote></div><br>