You need to sign in to do that
Don't have an account?

Apex super badge Automate record creation.
Hi all,
I am new to this platform help me out from this problem,
I am working on Apex super badge.
Automate record creation
I have created a class from the business requirements
here is my Apex class
Variable does not exist: caseIds
getting this error can anyone tell me where i have maid mistake.
I am new to this platform help me out from this problem,
I am working on Apex super badge.
Automate record creation
I have created a class from the business requirements
here is my Apex class
global class MaintenanceRequestHelper{ //Map to hold the incoming cases from the Trigger Set<Id> ids = new Set<Id>(); //List to hold the case for processing List<Case> casesForProc = new List<Case>(); //List to hold the case we will load List<Case> casesToInsert = new List<Case>(); //Method called by the Trigger to kick off the process public void updateWorkOrders(Set<Id> ids){ this.ids = ids; getData(); createNewCases(casesForProc); insert(casesToInsert); } //Use the ids Set to query the database for the newly modified cases //passed in this trigger, get the data we need for the new cases we //will create as a result. private void getData(){ casesForProc=[SELECT Id,Type,Vehicle__c,Equipment__c FROM Case WHERE Id in :ids and Type='Repair' and isClosed=True]; } //Use the idMap to query the Work Parts TAble, Then use that to get the min //cycle date from the product2 (aka Equipment) table. private void getMinCycleDate(){ //Get each work parts cycle date List<Work_Part__c> wpl = [SELECT Id, Type, Vehicle__c, Equipment__c, (SELECT Id, Equipment__r.Maintenance_Cycle__c // <-- Subquery FROM Work_Parts__r ORDER BY Equipment__r.Maintenance_Cycle__c ASC) FROM Case WHERE Id IN : caseIds AND isClosed = true AND (Type = 'Repair' OR Type = 'Routine Maintenance')]; Integer cycleDays = case.Work_Parts__r[0].Equipment__r.Maintenance_Cycle__c.intValue(); //Stuck here, I need to get the min date of the work parts withn each case. //so in SQL, it's just join the Case to the Work Part to the Product 2 //table, and take the min date, group by Case ID. But it seems you cannot //aggregate in SOQL on a sub-query, which is how I think you go from Case //down to Equipment (aka Product2) } private void createNewCases(List<Case> casesForProc){ for (Case oldCase: casesForProc){ Case newCase = new Case(); newCase.Type='Routine Maintenance'; newCase.Vehicle__c=oldCase.Vehicle__c; newCase.Equipment__c=oldCase.Equipment__c; newCase.Subject='Routine Maintenance Follow Up'; newCase.Date_Reported__c=Date.Today(); newCase.Date_Due__c=Date.Today();//+Min cycle date when I get it; newCase.Status='New'; newCase.Origin='Automated'; casesToInsert.add(newCase); } } }
Variable does not exist: caseIds
getting this error can anyone tell me where i have maid mistake.
May I suggest you please check with below link from stack exchange community with similar requirement.
http://salesforce.stackexchange.com/questions/130242/superbadges-apex-specialist-the-maintenancerequest-trigger-does-not-appear
Please mark this as solved if it's resolved so that it gets removed from the unanswered queue which results in helping others who are encountering similar issue.
Best Regards,
Nagendra.