Superbadge – Apex Specialist
I have completed the Apex Specialist Superbadge recently and have got 5000 points. Since I see some folks are having issues passing the challenge – thought of putting the configuration and code developed for the same. The details, requirement & Use Case is provided at the Trailhead website Superbadge Apex Specialist.
Step 1 : Install this unmanaged package. [ https://login.salesforce.com/packaging/installPackage.apexp?p0=04t36000000i5UM ]
follow the instruction given on trailhed site to install this package.
Step 2 : Rename Case with Maintenance Request
Step 3 : Rename Product with Equipment
for rename follow this ==> Setup –> Customize –> Tab Names and Labels –> Rename Tabs and Labels
As you install the package the required custom object and the dummy classes will automaticlly created for you.
Step 4: Now from here your super badge is starting . before processed further please go threw the requirements of this super badge on trailhed site.
Create classes and triggers as follow :
Create Trigger “‘MaintenanceRequest”
Create trigger helper class “MaintenanceRequestHelper”
trigger MaintenanceRequest on Case (before update, after update) { // call MaintenanceRequestHelper.updateWorkOrders ......
public class MaintenanceRequestHelper { public static void updateWorkOrders(Map<Id, Case> applicableCases){ ......
Create Test class “MaintenanceRequestTest”
@isTest public class MaintenanceRequestTest { ......
you can find the complete code over the git repo – [https://github.com/amitjpr/Thailhead-Solutions/tree/master/Superbadges/Apex]
Hi!
Thanks for this post! I got two question where I cant understand your code. Could you please clarify that for me?
1. One of the requirements was that if a Maintenance Request (Case) has several Work Parts related to it, the Due Date of the Maintenance Request shall be calculated by taking the Lifespan of the Work Part related Product that has the shortest lifespan. Where is this requirement reflected in your code? It appears to me your code simply takes randomly the lifespan of a related product.
2. In the class “MaintenanceRequestHelper” you create the Map “mapProduct” by putting the Product-Id as the Key and the Lifespan as the related value. Later on, when you create the case you pass the Case-Id into the map to get the lifespan (mapProduct.get(a.Id) ). I cant understand how this can possibly work as you have Product-Ids available a the Key.
Thanks in advance for your help and keep up the great work!
Best regards.
Michael
LikeLike
Please go threw the carefully , you will understand both .
LikeLike
I tried and it works flawlessly. Thanks … Expecting for other challenges as well
LikeLiked by 1 person