0

I am able to log in to Salesforce through the API in php. Brief Code:

define('USERNAME', getenv(<myuserkey>));
define('PASSWORD', getenv(<mypwkey));
define('SECURITY_TOKEN', getenv(mytokenkey));

$sfconn = new SforceEnterpriseClient();
$sfconn->createConnection('soap/sfwsdl.xml');
$sfconn->login(USERNAME,PASSWORD . SECURITY_TOKEN);

Later, I call a query like this:

$sfqry = "SELECT Id, QualifiedApiName, NamespacePrefix, DeveloperName, MasterLabel, Label, PluralLabel, DefaultCompactLayoutId, IsCustomizable, IsApexTriggerable, IsWorkflowEnabled, IsCompactLayoutable, KeyPrefix, IsQueryable from entitydefinition";
$response = $sfconn->query($sfqry);

I get data results back, the usual 'object' which has a 'records' property. But in looking at the list in records, EVERY single 'Id' value is the same - e.g. 000000000AAA (15 zeros, 3 A's). Other data looks fine (e.g. QualifiedApiName and other fields are different for each record). I have used the same query in the Salesforce SOQL page and Ids are definitely different - and the other fields match what I'm getting back through my PHP query.

I have queried other objects as well, and they too seem to be returning 00000000000AAA for the Id.

In the XML file I have set up, I see the base definition of SObject as this:

    <!-- Base sObject (abstract) -->
    <complexType name="sObject">
        <sequence>
            <element name="fieldsToNull" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
            <element name="Id" type="tns:ID" nillable="true" />
        </sequence>
    </complexType>

And, of course, I see the other objects being based off that one.

I've been researching this for over 2 days. I'm afraid I may have missed something very basic since I can't find anyone else reporting this problem.

Charlie
  • 115
  • 2
  • 9
  • I'm not 100% sure, but I believe you need to use "durableId" if you're looking for the id value of meta data. – Psymn Feb 14 '21 at 08:27

1 Answers1

0

Id's in EntityDefinition, FieldDefinition are so-so, they often return a fake id. It's quite interesting topic, read The requested resource does not exist [error] in Salesforce. What is wrong with Salesforce? if you want to know more.

Use DurableId, QualifiedApiName etc for uniqueness. What do you even need IDs for? Some url hacking attempt? That's not an official API...

eyescream
  • 18,088
  • 2
  • 34
  • 46
  • My main use of id values is for synchronization (external db). I'm working an Enterprise-wide automated data dictionary (side note: way beyond table/field names/data types, but that's a different topic). As you pointed out using QualifiedApiName for EntityDefintion/FieldDefinition will be enough for me in this case. I wanted to make sure I was not missing something basic. Other data queries seem to be giving me the hoped for IDs. Thanks for the response. At least I know I'm not insane (about these observations at least ). – Charlie Feb 16 '21 at 12:57