function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RstrunkRstrunk 

Need a Soql Query

 

 

 

   I have a custom field on the case object.  That custom field is named Last_Activity_Date__c.  It has a data type of Date/Time.

 

The Last_Activity_Date__c field is updated by a cross object field update.  The cross object field update is triggered from a

 

workflow rule on the caseComment object.  The workflow rule with field update is working correclty.  However, as a workflow

 

rule can only be triggered on insert or update, I would need a way to retro-actively go back and modify the Last_Activity_Date__c

 

on cases that are no longer having caseComment updates.  

 

 

 

 

So my thinking is that I could do a SOQL query and make a list of all cases where the Last_Activity_Date__c is less than the

lastModifiedDate on the most recent related case comment.  The problem is that I can't seem to create the query.  

 

Any help would be greatly appreciated!

 

 

 

 

I ALWAYS GIVE KUDOS AND IF A SOLUTION IS FOUND, I ALWAYS MARK IT AS SUCH.

 

THANKS

 

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox
We don't have a way to query for "WHERE A.B < C.D". Instead, you can take one of three basic approaches:

1) Query all case comment records by date ascending, and update all of them. I'd probably configure the workflow rule to trigger on all updates just long enough to update the case records correctly.

2) Run a report, download to excel or some offline database, sort and filter, and then update all the cases through an integration, such as Data Loader or Excel Connector.

3) Same as 2, but use a tool that's designed to query for data like this, such as Crystal Reports or DemandTools. Unfortunately, these cost money.