Relationships.....

Can you pull related records when doing using ‘get_entry_list’ call to get a list of record? I am having problems using the link_name_to_fields_array option to get data from another module with which it has a one to many relationship.

Module A is Opportunities. Module B is Vehicles. One Vehicle is be related to many Opportunities.

When I do a get_entry_list call to get a list of opportunities I want to return the related vehicle with the opportunity.

I tried adding the field to the selected fields array and I tried link_name_to_fields_array option but neither is working. What am I doing wrong?

Code Below


$get_entry_list_parameters = array(

         //session id
         'session' => $session_id,

         //The name of the module from which to retrieve records
         'module_name' => 'Opportunities',

         //The SQL WHERE clause without the word "where".
         'query' => 'sales_stage IN ("Sent","Completed","Trip")',

         //The SQL ORDER BY clause without the phrase "order by".
         'order_by' => "",

         //The record offset from which to start.
         'offset' => '0',

         //Optional. A list of fields to include in the results.
         'select_fields' => array(
			'trapsort_unit_c',
			'name',
			'id',
			'v_vehicles_module_opportunities_1_name'
         ),

         /*
         A list of link names and the fields to be returned for each link name.
         Example: 'link_name_to_fields_array' => array(array('name' => 'email_addresses', 'value' => array('id', 'email_address', 'opt_out', 'primary_address')))
         */
       'link_name_to_fields_array' => array(array('name'=>'v_vehicles_module_opportunities_1','value'=>array('name','id'))),

         //The maximum number of results to return.
         'max_results' => '1',

         //To exclude deleted records
         'deleted' => '0',

         //If only records marked as favorites should be returned.
         'Favorites' => false,
    );

things that for me are wrong,

This is a link_field I don’t think you can call it directly in the opportunities module, that why link_name_to_fields_array is it for

 'v_vehicles_module_opportunities_1_name'

Are you sure this is the right link_field_name?

'v_vehicles_module_opportunities_1',

You’re missing a comma here

'Favorites' => false,

Also, try to set it so you don’t have like the first one has no relationships, just to test

'max_results' => '',

best regards

Thanks for the reply. I have some new details to provide maybe that can help me get this solved.

  1. If I switch to a get_entry call and supply an id I get back the field I want by putting ‘v_vehicles_module_opportunities_1_name’ in the select_fields option.

  2. When I do a get_entry_list call with ‘v_vehicles_module_opportunities_1’ in the select fields options that field comes back with no value.

Any thoughts on how to proceed?