XML-RPC - How to fetch values of custom fields associated with opportunities?

Hello! I am using the XML-RPC API. I have 2 custom fields associated with opportunities that I would like to pull the values of. Everything I have tried, so far, has results in me being able to show the Infusionsoft_DataFormField object of the custom field. However, I have not been successful in retrieving the values contained within those custom fields.

Below is some sample PHP code that I am using:

$MyISOpportunityID = 3321; // MY OPPORTUNITY ID
$Opportunity_Custom_Field = ‘_CustomField1’; // THIS IS ONE OF THE TWO CUSTOM FIELDS CONNECTED TO AN OPPORTUNITY

$LeadInfo = Infusionsoft_DataService::query( new Infusionsoft_Lead(), array( ‘Id’ => $MyISOpportunityID));

$Test_This = array_shift($LeadInfo);

$customField = Infusionsoft_CustomFieldService::getCustomField($Test_This, $Opportunity_Custom_Field);

var_dump($customField);

From the above code, I get this output:

object(Infusionsoft_DataFormField)#41 (4) {
[“fields”:protected]=>
NULL
[“table”:protected]=>
string(13) “DataFormField”
[“data”:protected]=>
array(9) {
[“DataType”]=>
int(13)
[“Id”]=>
int(9)
[“FormId”]=>
int(-4)
[“GroupId”]=>
int(5)
[“Name”]=>
string(5) “CustomField1”
[“Label”]=>
string(6) “Custom Field 1”
[“DefaultValue”]=>
NULL
[“Values”]=>
NULL
[“ListRows”]=>
int(0)
}
[“appPoolAppKey”:protected]=>
string(22) “xxxx.infusionsoft.com
}

I’m needing to pull the custom field values from opportunities that I specify.

Any help is greatly appreciated! Thanks in advance!

Hi Zack, it is straight forward to do. When using the Query function you can pass the normal and custom fields (with the underscore prefix) that you want to return.

https://developer.infusionsoft.com/docs/xml-rpc/#data-query-a-data-table

If you do not know what those Custom Field names are, then querying the DataFormField table will reveal the information.

https://developer.infusionsoft.com/docs/table-schema/#DataFormField

Thanks @Pav. Below is the code that I am using and the output from the code. I am able to obtain the opportunity and the custom field, however, I am not seeing the values of the custom field. In the _45Day custom field, there is a date. There is not a default value that is ever populated in to that field; that field is manually populated. In this example, this opportunity does have a date (I verified that in the UI). Below is the code and output:

Code:

<?php error_reporting(E_ALL); // Load Infusionsoft require 'Infusionsoft/infusionsoft.php'; // Load config file (copy config.sample.php to config.php and put your clientid (key) and secret in. require 'Infusionsoft/config.php'; $MyISOpportunityID = 3321; $Opportunity_Custom_Field = array('Name', '_45Day'); $LeadInfo = Infusionsoft_DataService::query( new Infusionsoft_Lead(), array( 'Id' => $MyISOpportunityID), $Opportunity_Custom_Field); var_dump($LeadInfo); ?>

Output:

array(1) {
[0]=>
object(Infusionsoft_Lead)#51 (5) {
[“customFieldFormId”]=>
int(-4)
[“fields”:protected]=>
NULL
[“table”:protected]=>
string(4) “Lead”
[“data”:protected]=>
array(19) {
[“Id”]=>
int(3321)
[“OpportunityTitle”]=>
string(12) “Zack Olinger”
[“ContactID”]=>
int(57959)
[“AffiliateId”]=>
int(0)
[“UserID”]=>
int(162771)
[“StageID”]=>
int(65)
[“StatusID”]=>
int(8)
[“Leadsource”]=>
NULL
[“Objection”]=>
NULL
[“ProjectedRevenueLow”]=>
float(0)
[“ProjectedRevenueHigh”]=>
float(0)
[“OpportunityNotes”]=>
NULL
[“DateCreated”]=>
string(17) “20180608T15:01:44”
[“LastUpdated”]=>
string(17) “20190619T23:28:13”
[“LastUpdatedBy”]=>
int(162771)
[“CreatedBy”]=>
int(162771)
[“EstimatedCloseDate”]=>
NULL
[“NextActionDate”]=>
string(17) “20180709T00:00:00”
[“NextActionNotes”]=>
string(22) “End of 2 year warranty”
}
[“appPoolAppKey”:protected]=>
string(22) “xxxx.infusionsoft.com
}
}


Apparently I am executing the wrong query. Can someone please correct my query?

Thanks again for all of the help!

Are you using another SDK instead of Infusionsoft SDK?

Hi @Pav, yes I am - and that is embarrassing to realize; I apologize. I also believe that I have found a way to get all of the data I am looking for via the execution of saved searches.

Thanks for the help!