I want to auto-close all the opportunities 60 days after Action_By_date__c and Stage is Imported. Opportunity must be closed by system where Stage = System Closed and Closed reason = Expired. When I try to push code it says Expression cannot be assigned due to "opp.Action_By_Date__c = 'opp.Action_By_Date__c + 60'". I am not sure how could I check for opportunities 60 days after Action_By_date__c.
public class CloseOpportunityBatch implements Database.Batchable<SObject> {
public Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(
'SELECT Id, StageName, Action_Date__c, Closed__c' +
'FROM Opportunity' +
'WHERE StageName =\'Imported\' '
);
}
public void execute(Database.BatchableContext bc, List<Opportunity> opportunity) {
for( Opportunity opp : opportunity ) {
if (opp.StageName == 'Imported' && opp.Action_Date__c = 'opp.Action_Date__c + 60' ) {
opp.StageName = 'System Closed';
opp.Closed__c = 'Expired';
}
update opp;
}
}
public void finish(Database.BatchableContext bc) {
}
}