-
The salesforce introspection endpoint has different types, native (string, boolean etc), reference fields, and child objects
-
A reference field is like a foreign key and will include a
Id
at the end of the field to indicate it is a reference to another table -
From the documentation
Reference Field
- However when querying against this field to get a LastModified you need to use the reference field name and not the underlying table name
So for an example field
{
aggregatable: true,
aiPredictionField: false,
autoNumber: false,
byteLength: 18,
calculated: false,
calculatedFormula: null,
cascadeDelete: false,
caseSensitive: false,
compoundFieldName: null,
controllerName: null,
createable: false,
custom: false,
defaultValue: null,
defaultValueFormula: null,
defaultedOnCreate: true,
dependentPicklist: false,
deprecatedAndHidden: false,
digits: 0,
displayLocationInDecimal: false,
encrypted: false,
externalId: false,
extraTypeInfo: null,
filterable: true,
filteredLookupInfo: null,
formulaTreatNullNumberAsZero: false,
groupable: true,
highScaleNumber: false,
htmlFormatted: false,
idLookup: false,
inlineHelpText: null,
label: 'Created By ID',
length: 18,
mask: null,
maskType: null,
name: 'CreatedById',
nameField: false,
namePointing: false,
nillable: false,
permissionable: false,
picklistValues: [],
polymorphicForeignKey: false,
precision: 0,
queryByDistance: false,
referenceTargetField: null,
referenceTo: [ 'User' ],
relationshipName: 'CreatedBy',
relationshipOrder: null,
restrictedDelete: false,
restrictedPicklist: false,
scale: 0,
searchPrefilterable: false,
soapType: 'tns:ID',
sortable: true,
type: 'reference',
unique: false,
updateable: false,
writeRequiresMasterRead: false
}
CreatedById
reference to the User
table however when querying we need to query against CreatedBy
SELECT
Id,
LastModifiedDate,
(SELECT Id, LastModifiedDate FROM Tasks WHERE LastModifiedDate > 2024-07-22T17:58:17.363Z),
(SELECT Id, IsDeleted, LastModifiedDate FROM RelatedRecords WHERE LastModifiedDate > 2024-07-22T17:58:17.363Z),
AccountId,
MasterRecordId,
OwnerId
CreatedById,
FROM Contact
WHERE LastModifiedDate > 2024-07-22T17:58:17.363Z OR
Account.LastModifiedDate > 2024-07-22T17:58:17.363Z OR
Contact.LastModifiedDate > 2024-07-22T17:58:17.363Z OR
Owner.LastModifiedDate > 2024-07-22T17:58:17.363Z OR
CreatedBy.LastModifiedDate > 2024-07-22T17:58:17.363Z