The line "Integer days =" has an error, which I am trying to bind the Case record id to get "days" to be passed to the "createCase.Date_Due__c = date.today() + days; " Equipment__c is a lookup field on Case to Product2. What is wrong here? Thanks for your help!
public with sharing class MaintenanceRequestHelper {
public static void updateWorkOrders(List<Case> newCase, Map<Id,Case> oldMapCase) {
List<Case> caseList = new List<Case>();
for (Case thisCase: newCase)
{
Integer days = [Select Maintenance_Cycle__c from Product2 where id =:thisCase.Equipment__c];
if (thisCase.Status=='Closed' && oldMapCase.get(thisCase.id).Status != 'Closed'){
Case createCase = new Case();
createCase.RecordTypeId = '0124W00000160QvQAI';
createCase.subject = 'New Case Created';
createCase.Equipment__c = thisCase.Equipment__c;
createCase.Date_Due__c = date.today() + days;
caseList.add(createCase);
}
}
insert caseList;
}
}
List<SObject>
in most cases, and that can't be converted to anInteger
without a bit more work. What is the type of yourMaintenance_Cycle__c
field?