AnsweredAssumed Answered

How do you query on opportunities and include information from a related account?

Question asked by Ben Star on Apr 5, 2014
Latest reply on Apr 16, 2014 by bstar bstar
I am trying to run a query on Opportunities and everything works great, but now I need to include in the results billing_address_state which is on the account page. How can I grab that field when searching Opportunities.

'module_name' => 'Opportunities',
          //The SQL WHERE clause without the word "where".
          //accounts.id = '$select_account'
          //'query' => $query_where,
          //'query' => "sales_stage = '$sales_type_search' AND year(date_closed) = '$year_search'",
          'query' => "year(date_closed) = '$year_search' $sales1 $user_select1 $gut_select",
          //'query' => "year(date_closed) = '$year_search'",

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

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

          //Optional. A list of fields to include in the results.

          'select_fields' => array(
               'id',
               'name',
               'amount',
               'sales_stage',
               'probability',
               'date_closed',
               'assigned_user_name',
               'assigned_user_id',
               'opportunity_type',
               'gutfeeling_c'

          ),

           'link_name_to_fields_array' => array(
               array(
                    'name' => 'Accounts',
                    'value' => array(
                         'districtofficecounty_c',
                         'billing_address_state',
                    ),
               ),
           ),

Outcomes