CRM Open Source Business & Social CRM Software

Results 1 to 3 of 3

Thread: SOAP- Why it insert upto 50 records only?

  1. #1
    webnetin is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    68

    Question SOAP- Why it insert upto 50 records only?

    Hello All,

    I am stuck with a peculiar problem while using SOAP to pull data from an ERP system (MySQL based) onto my Sugar Installation.

    One of the table in ERP system is having around 800 records.
    While using following custom soap code, it is only able to insert approx 50 records at a time.
    (in default first 50 records)

    If I make change in query to extract say from after 100th records, it extracts only for upto 150 record, and insert to my Sugar deployment.

    I tried commenting the SOAP code, and displays the extracted record on log file, it shows all 800+ records. This points that issue is somewhere in SOAP code, or IS there any config which defines the limit on using?

    Any help will be highly appreciable.

    My Environment- Win2K3 server, Apache, PHP5.2, MySQL 5,

    Code:
    <?php
    
    define('sugarEntry', TRUE);
    require_once('erpconfig.php');
    $hf = fopen("MANUFACT_soap.log","a");
    //fwrite($hf, "\n*********************From Sugar-");
    	require_once('../include/nusoap/nusoap.php');
    	// change the URL here to point to your Sugar installation
    	$soapclient = new nusoapclient($soapurl,true);
    	$user_auth = array(
    	'user_auth' => array(
    	'user_name' => $soapuser,
    	'password' => md5($soappaswd),
    	'version' => '0.1'
    	),
    	'application_name' => 'MANUFfrm');
    	$result_array = $soapclient->call('login',$user_auth);
    	$session_id = $result_array['id'];
    
    	$user_guid = $soapclient->call('get_user_id',$session_id);
    //fwrite($hf, "\n*********************Opening DB-");
    
    $g_link = mysql_connect( $dbhost, $dbuser, $dbpasswd) or die('Could not connect to mysql server.' );
    mysql_select_db($db, $g_link) or die('Could not select database.');
    $qry = "SELECT manufacturers_id as manuf_id, manufacturers_name as name FROM manufacturers ORDER BY manufacturers_id";
    $sqlresult = mysql_query($qry);
    while ($row = mysql_fetch_assoc($sqlresult)) {
    	$man_id =  $row['manuf_id'];
    	$cname =  str_replace('®','',$row['name']);
    	$cname =  str_replace(",","",$cname);
    	$cname =  str_replace(".","",$cname);
    
    	$list_order = $row['manuf_id'];
    	$status = 'Active';
    
    	fwrite($hf, "\n\nManufacturer---->".$man_id."#mname.....".$cname);
    
    //FIRST CHECK IF THE RECORD IS AVAILABLE IT IS TO UPDATE
    								$sman_id=NULL;
    								$prcat_list_params = array(
    								'session' => $session_id,
    								'module_name' => 'Leads',
    								'query' => 'leads_cstm.list_order_c = "' . $list_order . '"',
    								'offset' => 0,
    								'select_fields' => array('id'),
    								'max_results' => 1,
    								'deleted' => 0
    								);
    								$prcat_list_array = $soapclient->call('get_entry_list',$prcat_list_params);
    
    								$prcat_id = $prcat_list_array['entry_list'][0]['name_value_list'][0]['value'];
    //fwrite($hf, "\nIF THE RECORD IS AVAILABLE IT IS TO UPDATE.....".$prcat_id);
    
    	if(isset($prcat_id)){
    		$set_entry_params = array(
    		'session' => $session_id,
    		'module_name' => 'Leads',
    		'name_value_list'=>array(
    		array('name'=>'id','value'=>$prcat_id),
    		array('name'=>'name','value'=>$cname),
    		array('name'=>'list_order_c','value'=>$list_order),
    		array('name'=>'status_c','value'=>$status),
    		array('name'=>'assigned_user_id', 'value'=>$user_guid)));
    	} else{
    			$set_entry_params = array(
    			'session' => $session_id,
    			'module_name' => 'Manufacturers',
    			'name_value_list'=>array(
    			array('name'=>'name','value'=>$cname),
    			array('name'=>'list_order_c','value'=>$list_order),
    		array('name'=>'status_c','value'=>$status),
    			array('name'=>'assigned_user_id', 'value'=>$user_guid)));
    
    	}
    //	fwrite($hf, "\nManufacturer now ready to set at Sugar Lead...............");
    		$result = $soapclient->call('set_entry',$set_entry_params);
    		$acctid = $result['id'];
    		fwrite($hf, "\nLead ID generated.....".$acctid);
    		fwrite($hf, "\nManuf ID error:".$soapclient->error_str);
    
    }
    
    // Free the resources associated with the result set
    // This is done automatically at the end of the script
    mysql_free_result($sqlresult);
    fwrite($hf, "\n**************************Closing the file***********");
    	fclose($hf);
    
    ?>

  2. #2
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,587

    Default Re: SOAP- Why it insert upto 50 records only?

    This happens because the php timeout was reached.
    The SOAP operations take a relatively long time.
    You can change your php-timeouts in php.ini and see how many SOAP
    operations will run in that changed time.
    The best way would be to write some kind of a queue page which works on one record only and then redirects to itself to work on the next record in the queue.
    Harald Kuske
    Pre-Sales Engineer DACH
    SUGARCRM Deutschland GmbH
    Crusiusstrasse 1, Munich, Germany 80538
    Email:
    hkuske@sugarcrm.com
    Home:
    http://www.sugarcrm.com

  3. #3
    webnetin is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    68

    Thumbs up Re: SOAP- Why it insert upto 50 records only?

    Thanks kuske

    And sorry on being late to say you thanks.

    Yes it was the PHP's maximum_execution_time issue

    and to solve this I just placed following line in the top of code
    Code:
    <?php
    
    ini_set('max_execution_time', 0);
    define('sugarEntry', TRUE
    And now i am able to get the 6000+ records process (now added as batch job)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 2009-02-12, 02:06 PM
  2. Problem to insert records in logic hooks
    By sugar78 in forum Developer Help
    Replies: 2
    Last Post: 2008-11-12, 02:07 PM
  3. Replies: 6
    Last Post: 2007-07-10, 03:05 AM
  4. how to insert the added custom fields through soap
    By laxmiprasanna9 in forum Help
    Replies: 0
    Last Post: 2007-01-16, 05:49 PM
  5. how to insert the added custom fields through soap
    By laxmiprasanna9 in forum Help
    Replies: 0
    Last Post: 2007-01-16, 05:48 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •