I'm in the process of doing some development in a random1 client org where they want an integration with another parties managed package.
Part of this is to run SOQL queries against custom objects and fields from the managed package.
As part of my testing I was running the following query successfully in the Developer Console Query Editor.
Select Id, SBQQ__Primary__c, SBQQ__Opportunity__c from SBQQ__Quote__c
Yet when I tried to use the same SOQL query from a new Apex class it wouldn't save with the message:
No such column 'SBQQ__Opportunity__c' on entity 'SBQQ__Quote__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
Odd, as I can clearly see this field in the describeSObject Metadata for SBQQ__Quote__c (which is how I built up the SOQL query).
<fields> <aggregatable>true</aggregatable> <autoNumber>false</autoNumber> <byteLength>18</byteLength> <calculated>false</calculated> <cascadeDelete>true</cascadeDelete> <caseSensitive>false</caseSensitive> <createable>true</createable> <custom>true</custom> <defaultedOnCreate>false</defaultedOnCreate> <deprecatedAndHidden>false</deprecatedAndHidden> <digits>0</digits> <filterable>true</filterable> <groupable>true</groupable> <idLookup>false</idLookup> <inlineHelpText>Opportunity being quoted.</inlineHelpText> <label>Opportunity</label> <length>18</length> <name>SBQQ__Opportunity__c</name> <nameField>false</nameField> <namePointing>false</namePointing> <nillable>false</nillable> <permissionable>false</permissionable> <precision>0</precision> <queryByDistance>false</queryByDistance> <referenceTo>Opportunity</referenceTo> <relationshipName>SBQQ__Opportunity__r</relationshipName> <relationshipOrder>0</relationshipOrder> <restrictedPicklist>false</restrictedPicklist> <scale>0</scale> <soapType>tns:ID</soapType> <sortable>true</sortable> <type>reference</type> <unique>false</unique> <updateable>false</updateable> </fields>
deprecatedAndHidden is false.
The field section from the sObject Metadata is similar:
<fields> <fullName>SBQQ__Opportunity__c</fullName> <deprecated>false</deprecated> <description>Opportunity being quoted.</description> <externalId>false</externalId> <inlineHelpText>Opportunity being quoted.</inlineHelpText> <label>Opportunity</label> <referenceTo>Opportunity</referenceTo> <relationshipLabel>Quotes</relationshipLabel> <relationshipName>Quotes</relationshipName> <relationshipOrder>0</relationshipOrder> <reparentableMasterDetail>false</reparentableMasterDetail> <trackHistory>false</trackHistory> <trackTrending>false</trackTrending> <type>MasterDetail</type> <writeRequiresMasterRead>false</writeRequiresMasterRead> </fields>
How can I tell via the APIs (preferably describeSObject) that a field is deprecated in the managed package that defined it?
Update: I think I need something like the Package Version Header used by the REST API so I can indicate the specific version of the namespace I'm interested in. There is an equivalent header for the Partner WSDL - Package Versions and the Partner WSDL
1 Random as in not my regular orgs, I didn't just log into any org I could to start writing Apex)
2 I'm aware I could alter the Version Settings on the class/trigger in question to the older version of the managed package to access the field. However, that isn't my objective.