<span style="font-family: courier new,monospace;">Hi,</span><br><br><span style="font-family: courier new,monospace;">$record = $client-&gt;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;">
     &#39;account_no&#39;=&gt;&quot;$societe&quot;,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
     &#39;phone&#39;=&gt;&quot;$telephone2&quot;,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
     &#39;fax&#39;=&gt;&quot;$fax&quot;,</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 &quot;Creation Error! &quot; . $client-&gt;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-&gt;getRecordId($record[&#39;id&#39;]);<br>

     </span><span style="background-color: rgb(255, 255, 153);">echo &quot;new account id : $accountid &lt;br /&gt;&quot;;</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> &lt;<a href="mailto:ml@arceva.fr">ml@arceva.fr</a>&gt; 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> &lt;?php<br> <br> include_once(&#39;/var/www/site/access.php&#39;);        //logins site &amp; CRM<br> include_once(&#39;vtwsclib/Vtiger/WSClient.php&#39;);        //Librairie SOAP CRM<br> include_once(&#39;/var/www/site/www/sync/functions.php&#39;);<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(&quot;SELECT NULLIF(1, (SELECT MIN(sync_crm) FROM users))&quot;);<br>
 $verif1 = mysql_result($verif, 0, 0);<br> //echo&quot;$verif1&quot;;<br> if ($verif1 == &quot;&quot;)<br>    echo &quot;Nothing to sync&quot;;<br> else<br>    {<br>    //Comptage du nombre d&#39;utilisateurs à synchroniser<br>
    $test_needed = mysql_query(&quot;SELECT COUNT(0) FROM jos_users WHERE<br> sync_crm=0 GROUP BY sync_crm&quot;);<br>    $sync_needed = mysql_result($test_needed, 0, 0);<br>    //*echo &quot;number of non sync user : $sync_needed&quot;;<br>
    while ($sync_needed &gt;= 1)        //Boucle tant qu&#39;on a des users a<br> synchroniser<br>        {<br>            $result = mysql_query(&quot;SELECT id FROM users WHERE sync_crm=0&quot;);<br>            $current_user_sync = mysql_result($result, 0, 0);<br>
            //*echo &quot;&lt;br /&gt;Id of current sync user :<br> $current_user_sync&lt;br /&gt;&quot;;<br> <br>            //Extraction des infos de l&#39;utilisateur<br> <br>            $user_extend = mysql_query(&quot;SELECT * FROM<br>
 juser_extended_data WHERE user_id=&#39;$current_user_sync&#39;&quot;);<br>            $ident = mysql_query(&quot;SELECT * FROM users WHERE<br> id=&#39;$current_user_sync&#39;&quot;);<br>            $identity = mysql_result($ident, 0, name);<br>
            $name = explode(&quot;\n&quot;, $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&#39;extration des infos de l&#39;utilisateur<br> //bug start<br>            //Connexion au CRM<br>
            $client = new Vtiger_WSClient($crm_url);<br> <br>            $login = $client-&gt;doLogin($crm_username, $crm_accesskey);<br>            if(!$login)<br>                echo &#39;Login Failed&#39;;<br>            else<br>
                {<br>                /**/echo &quot;Login Successful&lt;br /&gt;&quot;;<br>                $module = &#39;Accounts&#39;;<br>                $module2 = &#39;Contacts&#39;;<br> <br>                $record = $client-&gt;doCreate($module,<br>
                    array(<br>                        &#39;account_no&#39;=&gt;&quot;$societe&quot;,<br>                        &#39;phone&#39;=&gt;&quot;$telephone2&quot;,<br>                        &#39;fax&#39;=&gt;&quot;$fax&quot;,<br>
                        &#39;siccode&#39;=&gt;&quot;$codeape&quot;,<br>                        &#39;industry&#39;=&gt;&quot;$secteur&quot;,<br>                        &#39;employees&#39;=&gt;&quot;$nbsalaries&quot;,<br>                        &#39;website&#39;=&gt;&quot;$site&quot;,<br>
                        &#39;ship_street&#39;=&gt;&quot;$adresse&quot;,<br>                        &#39;ship_pobox&#39;=&gt;&quot;$BP&quot;,<br>                        &#39;ship_code&#39;=&gt;&quot;$CP&quot;,<br>                        &#39;ship_city&#39;=&gt;&quot;$ville&quot;,<br>
                        &#39;ship_country&#39;=&gt;&quot;$pays&quot;,<br>                        &#39;bill_street&#39;=&gt;&quot;$adresse&quot;,<br>                        &#39;bill_pobox&#39;=&gt;&quot;$BP&quot;,<br>                        &#39;bill_code&#39;=&gt;&quot;$CP&quot;,<br>
                        &#39;bill_city&#39;=&gt;&quot;$ville&quot;,<br>                        &#39;bill_country&#39;=&gt;&quot;$pays&quot;,<br>                    )<br>                );<br> <br>                if($record) {<br>
                    $accountid = $client-&gt;getRecordId($record[&#39;id&#39;]);<br>                    }<br>                echo &quot;new account id : $accountid &lt;br /&gt;&quot;;<br> <br> //bug end<br> <br>                $record = $client-&gt;doCreate($module2,<br>
                    array(<br>                        &#39;firstname&#39;=&gt;&quot;$prenom&quot;,<br>                        &#39;lastname&#39;=&gt;&quot;$nom&quot;,<br>                        &#39;email&#39;=&gt;&quot;$email&quot;,<br>
                        &#39;phone&#39;=&gt;&quot;$telephone1&quot;,<br>                        &#39;title&#39;=&gt;&quot;$poste&quot;,<br>                        &#39;accountid&#39;=&gt;&quot;$accountid&quot;,<br>                    )<br>
                );<br> <br>                if($record) {<br>                    $contactid = $client-&gt;getRecordId($record[&#39;id&#39;]);<br>                    }<br>                echo &quot;new contact id : $contactid &lt;br /&gt;&quot;;<br>
 <br> <br> addPortalAccess($crmdbhost,$crmdb,$crmdbuser,$crmdbpasswd,$contactid,$username,$passwd);<br> <br> addDate($crmdbhost,$crmdb,$crmdbuser,$crmdbpasswd,$contactid);<br> <br>                mysql_query(&quot;UPDATE users SET sync_crm=1 WHERE<br>
 id=$current_user_sync&quot;);<br> <br>                $sync_needed--;<br>                }<br>        }<br>    }<br> ?&gt;<br> _______________________________________________<br> Reach hundreds of potential candidates - <a href="http://jobs.vtiger.com">http://jobs.vtiger.com</a><br>
 </blockquote></div><br>