Max_results > 12,000 rows

Hi.
I am trying to recover leads records, which can be 500, 10000, and more than 12000 records, they depend on WHERE conditions (‘Assigned’, ‘New’, ‘InProcess’ etc), sometimes they respond with null, has it happened to someone?

$args = array(                  
                'session' => $sessionID,  
                //The name of the module from which to retrieve records
                'module_name' => 'Leads',        
                //The SQL WHERE clause without the word "where".
                'query' => "",        
                //The SQL ORDER BY clause without the phrase "order by".
                'order_by' => "",        
                //The record offset from which to start.
                'offset' => 0,        
                //A list of fields to include in the results.
                'select_fields' => array(
                        'id',        
                        'full_name',
                        'phone_mobile',
                        'phone_work',
                        'email1',
                        'status',
                        'date_entered',
                        'assigned_user_name'                        
                ),                    
                //A list of link names and the fields to be returned for each link name.
                'link_name_to_fields_array' => array(),        
                //The maximum number of results to return.
                'max_results' => 20000, // DUMMY FOR GET ALL ROWS
                //If deleted records should be included in results.
                'deleted' => 0
            );
$result = $this->suiteCRM->callCurl('get_entry_list',  $args);

Hi,
did you have a look in the suitecrm.log-file? Maybe you reach a threshold (like php’s max_execution_time, or Suites default_limit / special_query_limit).

1 Like

Hi diligent.
Thanks for your reply, I solved it iterating by next_offset and in max_result I set it to 7,000 to have that request margin per iteration. I don’t have access to CRM settings, so I had to do it like this.

$data = [];          
            $cont = 0;
            $offset = 0;
            $iterate = true;
            do{
                $args = array(                                 
                    'session' => $sessionID,
                    //The name of the module from which to retrieve records
                    'module_name' => 'Leads',        
                    //The SQL WHERE clause without the word "where".                 
                    'query' => " leads.date_entered >= DATE_SUB(NOW(), INTERVAL 2 YEAR)",        
                    //The SQL ORDER BY clause without the phrase "order by".
                    'order_by' => "",        
                    //The record offset from which to start.
                    'offset' => $offset,        
                    //A list of fields to include in the results.
                    'select_fields' => array(
                            'id',        
                            'full_name',
                            'phone_mobile',
                            'phone_work',
                            'email1',
                            'status',
                            'date_entered',
                            'assigned_user_name'                        
                    ),                    
                    //A list of link names and the fields to be returned for each link name.
                    'link_name_to_fields_array' => array(),        
                    //The maximum number of results to return.
                    'max_results' => MAX_RESULTS_REST, //7000 default
                    //If deleted records should be included in results.
                    'deleted' => 0
                );        
               
             $result = $this->suiteCRM->callCurl('get_entry_list',  $args);                 
               foreach($result->entry_list as $item){                                    
                    $data[] = array(
                       work with fieds...
                    );
                }
                $cont += $result->result_count; //count for end while
                $offset = $result->next_offset; //for next iteration
                if($cont == $result->total_count) //validate totals
                    $iterate = false; //end when get all rows
            } while($iterate);