I have a before insert trigger that calls the following function:
private void setActualDate(List<RS_Assessment__c> newlist){
List<Id> activityList = new List<Id>();
for (Assessment__c assessment : newlist){
if (assessment.Activity__c != null && assessment.Activity__r.Actual_Date__c == null){
if (assessment.Activity__r.Last_Assessment_Date__c == null){
activityList.add(assessment.Activity__c);
}
}
}
List<RS_Activity__c> processesToUpdate = [SELECT Id FROM RS_Activity__c WHERE Id IN: activityList];
if (processesToUpdate.size() > 0){
for (RS_Activity__c act : processesToUpdate){
RS_Assessment__c assessment = [SELECT Id, Assessment_Date__c FROM RS_Assessment__c WHERE Activity__c =: act.Id LIMIT 1];
act.Actual_Date__c = assessment.Assessment_Date__c;
}
update processesToUpdate;
}
However, I get a attempt to deference a null object at the point of doing the assignment i.e. line 7. Is there a work around for this?
UPDATE: I have changed the code and now i get compilation error of: DML requires SObject or SObject list type : List