I have a Custom (Managed) object called Individual Email Result (et4ae5__IndividualEmailResult__c) which contains a Lookup field to a Contact record (et4ae5__Contact__c) and I want to create a schedulable Apex Class to execute daily and update all of the related Contact records (with specific data from the fields of the Individual Email Result record) when it detects that a particular Individual Email Result checkbox (MC_ANY_Sent__c) equals 'true'.
Here is the code that I have so far:
public class MCANYSent implements Schedulable, Database.Batchable<sObject>{
public void execute( SchedulableContext context )
{
Database.executeBatch( this );
}
public Database.QueryLocator start( Database.BatchableContext context )
{
return Database.getQueryLocator
( 'SELECT Id, MC_ANY_Sent__c, et4ae5__DateSent__c, Name, et4ae5__FromName__c, et4ae5__FromAddress__c, et4ae5__Contact__c'
+ 'FROM et4ae5__IndividualEmailResult__c'
+ 'WHERE MC_ANY_Sent__c = true'
);
}
public void execute( Database.BatchableContext context, List<et4ae5__IndividualEmailResult__c> individualemailresults )
{
for ( et4ae5__IndividualEmailResult__c ier : individualemailresults )
{
ier.et4ae5__Contact__r.MC_Date_of_Last_ANY_Sent__c = ier.et4ae5__DateSent__c;
ier.et4ae5__Contact__r.MC_Last_Email_Title__c = ier.Name;
ier.et4ae5__Contact__r.MC_Last_Email_Sender__c = ier.et4ae5__FromName__c + '(' + ier.et4ae5__FromAddress__c + ')';
}
update individualemailresults.et4ae5__Contact__c;
}
public void finish( Database.BatchableContext context )
{
// nothing to do here
}
}
However, when I try to save this, I am getting the following error; Error: Compile Error: Variable does not exist: et4ae5__Contact__c at line 25 column 39
Line 25 is the 'update individualemailresults.et4ae5__Contact__c;' line.
I don't need to update the Individual Email Result record, as it isn't being changed, so I'm only looking to update the Contact record in the Lookup field (et4ae5__Contact__c), where all of the changes have been made.
Any ideas?