Challenge Not yet complete... here's what's wrong: Closing a Maintenance Request of type 'Routine Maintenance' did not create of a new Maintenance Request related to the same Vehicle . Someone please help :(
Closing a maintenance request of type 'routine maintenance ' did not create of a new maintenance request related to same vehicle Its showing 13 errors bro please slove my problem😭
********************** MaintenanceRequestHelper Class ******************* public with sharing class MaintenanceRequestHelper { public static void updateworkOrders(List updWorkOrders, Map nonUpdCaseMap) { Set validIds = new Set();
For (Case c : updWorkOrders){ if (nonUpdCaseMap.get(c.Id).Status != 'Closed' && c.Status == 'Closed'){ if (c.Type == 'Repair' || c.Type == 'Routine Maintenance'){ validIds.add(c.Id);
} } }
if (!validIds.isEmpty()){ List newCases = new List(); Map closedCasesM = new Map([SELECT Id, Vehicle__c, Equipment__c, Equipment__r.Maintenance_Cycle__c,(SELECT Id,Equipment__c,Quantity__c FROM Equipment_Maintenance_Items__r) FROM Case WHERE Id IN :validIds]); Map maintenanceCycles = new Map(); AggregateResult[] results = [SELECT Maintenance_Request__c, MIN(Equipment__r.Maintenance_Cycle__c)cycle FROM Equipment_Maintenance_Item__c WHERE Maintenance_Request__c IN :ValidIds GROUP BY Maintenance_Request__c];
for (AggregateResult ar : results){ maintenanceCycles.put((Id) ar.get('Maintenance_Request__c'), (Decimal) ar.get('cycle')); }
for(Case cc : closedCasesM.values()){ Case nc = new Case ( ParentId = cc.Id, Status = 'New', Subject = 'Routine Maintenance', Type = 'Routine Maintenance', Vehicle__c = cc.Vehicle__c, Equipment__c =cc.Equipment__c, Origin = 'Web', Date_Reported__c = Date.Today()
Closing a Maintenance Request of type 'Routine Maintenance' did not create of a new Maintenance Request related to the same Vehicle. HELP ME FOR THIS QUERY
Close case not available and vehicle from details not available
Thank you so much Bro🤩 It’s working👍🏻💯
Inserting a new Maintenance Request of type different than 'Repair' and then closing it should not create a new Maintenance Request.
Same problem please replyy anyone how to resolve it
Challenge Not yet complete... here's what's wrong:
Closing a Maintenance Request of type 'Routine Maintenance' did not create of a new Maintenance Request related to the same Vehicle . Someone please help :(
Same problem .Solved the problem?
Everybody got this
@@MeghanaSripada-d6c how please tell
Same problem..
How to rectify that? Please let me know
where is the code ????????????????????????????????????
Can i do this module in diff organisation because i have tried a lot to do it in same org but wo ni ho rha h brooo.. please tell meee😭😭😭
Create a new playground and do all the steps from beginning
2:55
Thanks bro, it really helped
Glad it helped
Bro i am getting maintenance request.apxt 5 line error
Maintenance request option is not showing😭😭please help me
Closing a maintenance request of type 'routine maintenance ' did not create of a new maintenance request related to same vehicle
Its showing 13 errors bro please slove my problem😭
U got the solution?
********************** MaintenanceRequestHelper Class *******************
public with sharing class MaintenanceRequestHelper {
public static void updateworkOrders(List updWorkOrders, Map nonUpdCaseMap) {
Set validIds = new Set();
For (Case c : updWorkOrders){
if (nonUpdCaseMap.get(c.Id).Status != 'Closed' && c.Status == 'Closed'){
if (c.Type == 'Repair' || c.Type == 'Routine Maintenance'){
validIds.add(c.Id);
}
}
}
if (!validIds.isEmpty()){
List newCases = new List();
Map closedCasesM = new Map([SELECT Id, Vehicle__c, Equipment__c, Equipment__r.Maintenance_Cycle__c,(SELECT Id,Equipment__c,Quantity__c FROM Equipment_Maintenance_Items__r)
FROM Case WHERE Id IN :validIds]);
Map maintenanceCycles = new Map();
AggregateResult[] results = [SELECT Maintenance_Request__c, MIN(Equipment__r.Maintenance_Cycle__c)cycle FROM Equipment_Maintenance_Item__c WHERE Maintenance_Request__c IN :ValidIds GROUP BY Maintenance_Request__c];
for (AggregateResult ar : results){
maintenanceCycles.put((Id) ar.get('Maintenance_Request__c'), (Decimal) ar.get('cycle'));
}
for(Case cc : closedCasesM.values()){
Case nc = new Case (
ParentId = cc.Id,
Status = 'New',
Subject = 'Routine Maintenance',
Type = 'Routine Maintenance',
Vehicle__c = cc.Vehicle__c,
Equipment__c =cc.Equipment__c,
Origin = 'Web',
Date_Reported__c = Date.Today()
);
If (maintenanceCycles.containskey(cc.Id)){
nc.Date_Due__c = Date.today().addDays((Integer) maintenanceCycles.get(cc.Id));
} else {
nc.Date_Due__c = Date.today().addDays((Integer) cc.Equipment__r.maintenance_Cycle__c);
}
newCases.add(nc);
}
insert newCases;
List clonedWPs = new List();
for (Case nc : newCases){
for (Equipment_Maintenance_Item__c wp : closedCasesM.get(nc.ParentId).Equipment_Maintenance_Items__r){
Equipment_Maintenance_Item__c wpClone = wp.clone();
wpClone.Maintenance_Request__c = nc.Id;
ClonedWPs.add(wpClone);
}
}
insert ClonedWPs;
}
}
}
*************************** MaintenanceRequest trigger class ****************************
trigger MaintenanceRequest on Case (before update, after update) {
if(Trigger.isUpdate && Trigger.isAfter){
MaintenanceRequestHelper.updateWorkOrders(Trigger.New, Trigger.OldMap);
}
}
Thank you bro, it was very helpful..
thankyou this helped me
Hi
Hi bro it showing 13 errors in program please slove my problem
@@munagasaiteja7922 whats the error?
Close case is not showing in feed
Did u found that?
@@komalchourasia5258 not yet bro🥲
Closing a Maintenance Request of type 'Routine Maintenance' did not create of a new Maintenance Request related to the same Vehicle.
HELP ME FOR THIS QUERY
U got the solution?
where is that whole code ???
bro i am not getting 'how we roll maintainance',how can i get it bro.
Please give me solution bro.....
bro install the unlocked package, it is given above
Maintenance request option is not showing😭😭
Yes
sir code de do
tnx bro
i have one doubt first we create objects and tabs right pls tel me
yes
Welcome buddy