Closed slimble closed 1 year ago
The reason this happens is you did not provide a getOrderBy() for your selector. If you omit this, the queryfactory defaults to CreatedDate using this code
public virtual String getOrderBy()
{
if(m_orderBy == null) {
m_orderBy = 'CreatedDate';
if(describeWrapper.getNameField() != null) {
m_orderBy = describeWrapper.getNameField().getDescribe().getName();
}
}
return m_orderBy;
}
Personally, I tend to use a getOrderBy() that returns an autonumber field by default, if one exists for the sobject as that makes writing tests easier
As @cropredyHelix said, the simple solution here is to define a getOrderBy
rather than rely on the default implementation
Hi there,
I am trying to query the ContentDocumentLink Object. When I write my query directly into my Service class as
List<ContentDocumentLink> cdlList = [SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId IN :contentDocIdSet];
it works fine however if I use this code in my service classSet<Id> contentDocIdSet = new Set<Id>(); for(ContentDocument con : contentDocumentList) { contentDocIdSet.add(con.Id); }
And the following in my selector class
`public with sharing class SRV_ContentDocumentLinkSelector extends fflib_SObjectSelector { public Schema.SObjectType getSObjectType() { return ContentDocumentLink.SObjectType; }
}`
I receive an error "Invalid Field 'CreatedDate' for object 'ContentDocumentLink' however this object does not contain a CreatedDate field