• john chris 8
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hi all,


1) what is community cloud? ]
2) how many types of communities?
3) how many types of licenses?


Best Regards,
John
chris
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
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.



 
Hi all,


1) what is community cloud? ]
2) how many types of communities?
3) how many types of licenses?


Best Regards,
John
chris