Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. @future(callout=true)public static void runWarehouseEquipmentSync(){, if(response.getStatusCode()==200){//System.debug(size of equipment +equipmentlist.size());List updateEquipmentlist=getProductlist(response);if(updateEquipmentlist.size() > 0){insert new List(updateEquipmentlist);}}}, public static List getProductlist(HttpResponse response){, List externalEquipment = (List) JSON.deserializeUntyped(response.getBody());List equipmentlist=new List();//System.debug(size of result+externalEquipment.size());for (Object externalEquipment1: externalEquipment) {Map data = (Map)externalEquipment1;//system.debug(externalEquipment1);//system.debug(data+===+data.get(cost));Product2 equipment=new Product2();//equipment.Id =(String)data.get(_id);equipment.Cost__c=(Integer)data.get(cost);equipment.Lifespan_Months__c =(Integer)data.get(lifespan);equipment.Maintenance_Cycle__c =(Integer)data.get(maintenanceperiod);equipment.Name =(String)data.get(name);equipment.Current_Inventory__c =(Integer)data.get(quantity);equipment.Replacement_Part__c =(Boolean)data.get(replacement);equipment.Warehouse_SKU__c=(String)data.get(sku);equipmentlist.add(equipment);}return equipmentlist;}, public static HttpResponse getrespond(){Http http=new Http();HttpRequest request=new HttpRequest();request.setEndpoint(WAREHOUSE_URL);request.setMethod(GET);HttpResponse res=Http.send(request);return res;}}, global class WarehouseSyncSchedule implements Schedulable{// implement scheduled code hereglobal void execute (SchedulableContext sc){, WarehouseCalloutService.runWarehouseEquipmentSync();//optional this can be done by debug modeString sch = 00 00 01 * * ?;//on 1 pmSystem.schedule(WarehouseSyncScheduleTest, sch, new WarehouseSyncSchedule());}}, @isTestpublic class MaintenanceRequestTest {, @isTest static void testMaintenanceRequest(){, List maintenanceList=new List();List maintenanceListAfterClosed=new List();Vehicle__c vehicle=new Vehicle__c(Name=tata sumo,Air_Conditioner__c=true,Model__c=23Test);insert vehicle;Product2 equipment=new Product2(Name=tire,Cost__c=100,Current_Inventory__c =10,Replacement_Part__c=true,Warehouse_SKU__c =test,Lifespan_Months__c =10,Maintenance_Cycle__c=10);insert equipment;for(Integer i=1;i<=300;i++){Case maintenance=new Case(Subject=Test subject+i,Type=Routine Maintenance+i,Status=New+i,Origin=Phone+i,Equipment__c=equipment.Id,Vehicle__c=vehicle.Id);maintenanceList.add(maintenance);}insert maintenanceList;// system.assertEquals(300, maintenanceList.size());for(Case caseupdate:maintenanceList){caseupdate.Status=Closed;caseupdate.Type=Routine Maintenance;caseupdate.Date_Due__c=date.Today().addDays(Integer.valueOf(equipment.Maintenance_Cycle__c));maintenanceListAfterClosed.add(caseupdate);}Test.startTest();//UPDATE maintenanceListAfterClosed;//Bulk insert updateDatabase.SaveResult[] updatequipment = Database.update(maintenanceListAfterClosed);Test.stopTest();for(Database.SaveResult sa:updatequipment){System.assert(sa.isSuccess());}}}, @isTestglobal class WarehouseCalloutServiceMock implements HttpCalloutMock {// implement http mock callout//Mock responce created to test the call outglobal HttpResponse respond(HttpRequest request){System.assertEquals(https://th-superbadge-apex.herokuapp.com/equipment', request.getEndpoint());System.assertEquals(GET, request.getMethod());HttpResponse response = new HttpResponse();response.setHeader(Content-Type, application/json);response.setBody([{_id:55d66226726b611100aaf741,replacement:false,quantity:5,name:Generator 1000 kW,maintenanceperiod:365,lifespan:120,cost:5000,sku:100003}]);response.setStatusCode(200);return response;}}, @isTestprivate class WarehouseCalloutServiceTest {// implement your mock callout test here@isTest static void TestWarehouseCalloutService() {Test.startTest();//mock respoonseTest.setMock(HttpCalloutMock.class, new WarehouseCalloutServiceMock());WarehouseCalloutService.runWarehouseEquipmentSync();Test.stopTest();}}, @isTest static void WarehousescheduleTest(){. System.debug(*** Total cases (expected 600): +numberAllCases); What is a word for the arcane equivalent of a monastery? @future maintenanceNew.Subject = 'Other'; Hey Nikhil. newCase.Vehicle__c=vehicle; For the first release, there are four Superbadges that you can earn: Apex Specialist I'm going to go into depth a little bit more about the Apex Specialist badge a little later on, but this one focuses heavily on apex customization via triggers, scheduled apex and apex callouts. for(AggregateResult res :wpc){ Hope this helps!Looking For? List lista = [ } SYSTEM.assertEquals(newReq.ProductId, equipmentId); Asking for help, clarification, or responding to other answers. Ask Question Asked 1 year, 3 months ago. Accelerate learning across your organization. Hi, Its giving error for me . Apex specialist superbadge challenge 4. Trailhead solution for Apex Specialist superbadge As bejng the solo running admin to this page i might not be able to update the solutions on short notice. please help. }. list workPartList = new list(); TimeZoneSidKey=America/Los_Angeles, UserName=stdtest@testorg.com); List caseList = new List(); Invalid type: Schema.Work_Part__c, Use variable as ProductId instaed of Equipment__c Test.setMock(HttpCalloutMock.class, new WarehouseCalloutServiceMock()); Challenge Not yet complete Here whats wrong: Set setIdCases = new Set(); Subject=REQUEST_SUBJECT, Apex Specialist is one of the superbadges of Salesforce trailhead(A New Approach to Learning Salesforce). @isTest $ sfdx force:source:retrieve -n NameOfThePackage This will retrieve all the components in the package into a new folder named as the package. You signed in with another tab or window. }. } This is an unofficial (no salesforce sponsorship) forum to discuss getting certified and building on salesforce platforms (force.com, heroku, exacttarget, slack, etc. Are you sure you want to create this branch? newCase.Subject=subjectCase; You have to insert as many work parts records for each inserted new case record. } newEMIRecordList.add(newEMIRecord); String joBID= System.schedule(TestScheduleJob, CRON_EXP, new WarehouseSyncSchedule()); If nothing happens, download Xcode and try again. } } Lightning Experience Specialist I have complete Idea of this coding bt I am not getting what to do before writing this code exactly for this challenge. Hi shruti. List EquipmentIDListUpdate = vehicleToEquipmentMap.get(MRRecord.Vehicle__c); else if(maintenanceCycle > EMIRecord.Equipment__r.Maintenance_Cycle__c){ This repository is for solving all the problems and pass all the challenges in the way of earning this superbadge. }, PRIVATE STATIC Equipment_Maintenance_Item__c createWorkPart(id equipmentId,id requestId){ Case newCase = mapOldCasesWithNewCases.get(idOld); list vehicleList = new list(); Map mapOldCasesWithItems, Map mapOldCasesWithNewCases){. update caseToUpdate; Product needs to be renamed as Equipment not Vehicle since Vehicle is already provided to us in the installed package. Case newMRRecord = new Case(); insert emptyReq; Equipment_Maintenance_Item__c workP = createWorkPart(equipmentId, emptyReq.Id); If you search regarding Apex on YouTube you'll find many more channels and videos. Apex specialist superbadge challenge 4. If nothing happens, download GitHub Desktop and try again. Set idOldCases = mapOldCasesWithNewCases.keySet(); Advanced-Apex-Specialist Showcase your mastery of business process automation without writing a line of code. private static final string REQUEST_ORIGIN = Web; Does ZnSO4 + H2 at high pressure reverses to Zn + H2SO4? Copyright 2000-2022 Salesforce, Inc. All rights reserved. for(Case MRRecord: newMap.values()){ cas.Status = 'Closed'; Set Up Development Org || Apex Specialist Superbadge Education Org's 283 subscribers Subscribe 75 Share 20K views 7 months ago Apex Specialist - Superbadge This is the pre-requisite for Apex. 'Apex Specialist' is one of the superbadges of Salesforce trailhead(A New Approach to Learning Salesforce). Contact contact = [SELECT Id, FirstName, LastName,Email,AccountId FROM Contact WHERE Email = test@test.com LIMIT 1]; Go to Setup > Apex Classes > Schedule a job like below: Edit the following in the Developer console. Hi the challenge has been updated. } for(Case caseInList: caseList){ I would recommend you to follow the blog rather than looking into the code. What sort of strategies would a medieval military use against a fantasy giant? for(Integer i_ok = 0; i_ok < 300; i_ok ++){ }, if(Trigger.isAfter){ case cs = new case(Type=REPAIR, REST APIJSONJSONApex ObjectJSON, , VisualforceLightning ComponentApexApexApex pr.Lifespan_Months__c = (Integer)productMap.get(lifespan) ; private static final string WORKING = Working; Apex Specialist Superbadge Null Reference on Challenge 4. 6. list requestList = new list(); Learn in-demand skills. Hi, So even though you know the concepts you'll have to check and understand what fits where. By rejecting non-essential cookies, Reddit may still use certain cookies to ensure the proper functionality of our platform. req.Status = CLOSED; }, public static void createNewEquipmentMaintenanceItem(Map newMap){ equipmentList.add(createEq()); You should definitely complete the task on your own and you can get all the help. REST APICall Salesforce, 2SalesforceApex SpecialistTips, , Work fast with our official CLI. private static final string STATUS_NEW = New; Check the name of the apex class created and match it in same fashion. Do lemme know if you find solutions codes that work well for it. private static final string CLOSED = Closed; Integer addDays=0; Apologies for m caught quite off guard at this moment. Test.startTest() Test.stopTest() , , startTeststopTest, A. Super BadgeUnlockTipsTrailheadTipsUnlock Http http = new Http(); if(response.getStatusCode() == 200) Vehicle__c Vehicle = new Vehicle__C(name = SuperTruck); Apologies for the codes have changed. trigger MaintenanceRequest on Case (before update, after update, before insert, after insert) { Origin=REQUEST_ORIGIN, HttpRequest request = new HttpRequest(); } newCase.Comments = New comment!; im geting error, newCase.Equipment__c = leastValueMap.get(c.Id).Equipment__c; Various trademarks held by their respective owners. if(res.get(cycle)!=null){ private class WarehouseSyncScheduleTest { This Superbadge challenge changed on 9th December 2020 , is above code for updated challenge? pr.Warehouse_SKU__c = (String)productMap.get(sku); Advanced Apex Specialist Superbadge - Step 3 Issue . for(Equipment_Maintenance_Item__c emi : emiList){ This is the message I get: Also some of the functions come predefined and it might be that as well. EquipmentIDListUpdate.add(EMIRecord.Equipment__c); } I want to know that which part of my code is wrong, not just answer. Issue with step #6 of the Lightning Web Components Specialist superbadge. maintenanceNew.Status = 'New'; Use the included package content to . Please Guide me.. Learn. This superbadges require a bit of practical experience in apex and all of them are not available on trailhead. Map vehicleToEquipmentMap = new Map(); This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Test automation logic || Apex Specialist Superbadge Education Org's 273 subscribers Subscribe 23 Share 6.4K views 6 months ago Apex Specialist - Superbadge This is Apex Specialist Superbadge. for(Id oldId : oldIdCases){ For Challenge 1 I am getting error for some of the fields that they doesnt exist like Vehicle__c, Equipment__c, Due_Date__c. What video game is Charlie playing in Poker Face S01E07? @isTest } Apex Specialist Superbadge Trailmix | Salesforce Trailhead Laura Thomas +19,700 Points +1,000 points Module Apex Triggers Write Apex triggers to perform custom database actions. tmpCases.add(newCases.get(oldId)); vehicleList.add(createVehicle()); We have a small group to help out each others. newMRRecord.Vehicle__c = MRRecord.Vehicle__c; Apex document.getElementById( "ak_js_1" ).setAttribute( "value", ( new Date() ).getTime() ); Ever loved someone so much, you would do anything for them? }. for(case req : requestList){ I used this code for MaintenanceRequestHelper: public with sharing class MaintenanceRequestHelper {. Stuck on Superbadge Apex Specialist Step 4? insert newItems; newCases = new List(); Please provide additional details in your answer. List newMRRecordList = new List(); newCase.Date_Reported__c = System.today(); Apex Specialist. } If u further need help you can join the telegram group from link on the homepage. }. public static void updateWorkOrders(List caseList) { if(c.Type == 'Repair' || c.Type == 'Routine Maintenance'){ else{ } for this code: @isTest I tried to use your code as it is and it gives error..For this superbadge I already read on 7th Dec that Superbadge challenge will be changed on 9th Dec and I am unaware about old superbadge so cant tell you what actual changes are. +13,000 points ~12 hrs App Builder Super Set Superbadge Complete the capstone assessment to earn the App Builder Super Set. ProductId=equipmentId, Variable does not exist: Equipment__c ( Automate record creation ), I face this error what can I do please Help me. ChangethelabelsforStandard Objectsand Fields in SalesforceGo to Setup -> Customize -> Tab Names andLabels->RenameTabs andLabels. And I might not be the best to advice on that particular section. newCase.Origin=web; Hi guys, I'm almost finished with the test to get tge Apex Specialist SuperBadge, I attempt to validate the "Test automation logic" but I can't really see what is my error or why is not passing. Equipment_Maintenance_Item__c e = new Equipment_Maintenance_Item__c(); Step 2. Hard times, Challenge 1 : Automate record creation List createdCases = [Select Id from Case where Type = Routine Maintenance]; }, //public static void updateWorkOrders() { contact.AccountId = acc.Id; newItem.Quantity__c = item.Quantity__c; Save my name, email, and website in this browser for the next time I comment. for(Integer i_ok = 0; i_ok < 300; i_ok ++){ If multiple equipments are used in the maintenance request, choose the shortest maintenance cycle to define the service date. same error for me too.. can you please help me out, hi insert newItems; List externalProducts = (List) JSON.deserializeUntyped(response.getBody()); Superbadges - Apex Specialist (The 'MaintenanceRequest' trigger does not appear to be handling bulk operations correctly) Hi guys, I'm almost finished with the test to get tge Apex Specialist SuperBadge, I attempt to validate the "Test automation logic" but I can't really see what is my error or why is not passing.