Skip to main content
added 336 characters in body
Source Link
Boris Bachovski
  • 16.3k
  • 8
  • 50
  • 88

As far as I can see, this would do the job:

[SELECT Id, Email__c FROM Project__c WHERE Criteria__c = :criteria ORDER BY Some_Date__c, External_Id__c DESC][0]

Therefore your function would be:

public Project__c getRecord(String criteria) 
{
    return [SELECT Id, Email__c FROM Project__c WHERE Criteria__c = :criteria ORDER BY Some_Date__c, External_Id__c DESC][0];
}

You can add try catch block to make sure you don't get exceptions if there no such records btw...

As far as I can see, this would do the job:

[SELECT Id, Email__c FROM Project__c WHERE Criteria__c = :criteria ORDER BY Some_Date__c, External_Id__c DESC][0]

As far as I can see, this would do the job:

[SELECT Id, Email__c FROM Project__c WHERE Criteria__c = :criteria ORDER BY Some_Date__c, External_Id__c DESC][0]

Therefore your function would be:

public Project__c getRecord(String criteria) 
{
    return [SELECT Id, Email__c FROM Project__c WHERE Criteria__c = :criteria ORDER BY Some_Date__c, External_Id__c DESC][0];
}

You can add try catch block to make sure you don't get exceptions if there no such records btw...

Source Link
Boris Bachovski
  • 16.3k
  • 8
  • 50
  • 88

As far as I can see, this would do the job:

[SELECT Id, Email__c FROM Project__c WHERE Criteria__c = :criteria ORDER BY Some_Date__c, External_Id__c DESC][0]