Opportunity custom fields are missing via DataService query

Opportunity custom fields are missing via DataService query for few records even though the value is present in the UI. That particular custom field name(CustomXXX) is included in the select field. The same query I used to query another opportunity, I got the value for CustomXXX. Below is the query I used for both API calls. The only change is the value given for “OpportunityTitle”

> <?xml version="1.0"?>
>         <methodCall>
>           <methodName>DataService.query</methodName>
>           <params>
>             <param>
>               <value>
>                 <string>XXXX</string>
>               </value>
>             </param>
>             <param>
>               <value>
>                 <string>Lead</string>
>               </value>
>             </param>
>             <param>
>               <value>
>                 <int>100</int>
>               </value>
>             </param>
>             <param>
>               <value>
>                 <int>0</int>
>               </value>
>             </param>
>             <param>
>               <value>
>                 <struct>
>                 <member>
>                     <name>OpportunityTitle</name>
>                     <value>
>                       <string>123 - Opportunity XXX</string>
>                     </value>
>                   </member>
>                 </struct>
>               </value>
>             </param>
>             <param>
>               <value>
>                 <array>
>                   <data>
>                     <value>
>                       <string>AffiliateId</string>
>                     </value>
>                     <value>
>                       <string>ContactID</string>
>                     </value>
>                     <value>
>                       <string>EstimatedCloseDate</string>
>                     </value>
>                     <value>
>                       <string>LastUpdatedBy</string>
>                     </value>
>                     <value>
>                       <string>_CustomXXX</string>
>                     </value>
>                   </data>
>                 </array>
>               </value>
>             </param>
>             <param>
>               <value>
>                 <string>LastUpdated</string>
>               </value>
>             </param>
>             <param>
>               <value>
>                 <boolean>0</boolean>
>               </value>
>             </param>
>           </params>
>         </methodCall>

Just want to make sure I’m clear on what you’re saying here:

If the opp title is the only thing different and you are actually using the name “_CustomXXX” then you should only get that field if you had a custom field named CustomXXX. Custom fields must be the DB name for each field. Could you clarify if you’re using the actual DB name or are you literally using ‘_CustomXXX’?

Yea right. Custom field name(’_CustomXXX’) is the DB name. I get values for few other records which means there is no issue with the query right. For two records(which I checked) I have the value for this custom field in the UI. It is a dropdown field. But I don’t get the value in the response.

Well, next thing would be to ask you to post the code snippet to see if anything sticks out.

Few things I observed

1.Opportunities that were created earlier don’t reflect the default value set for the newly created drop-down custom field.
2.Even if I create a new opportunity in Infusionsoft after the custom field with default value is created, the custom field is not set to the default value in the API response, unless I give a value in for some other field under the custom field tab and do a save.

The value is show in the UI but the reponse from the API doesnt include the value though the field is given under the select fields

To set a default value you will need to go into your admin->settings, click on application to the left and click into the opportunity system labels where you can then set the default values for any existing field.