Superbadge Apex Specialist Full Solutions - Salesforce Handle (2024)

Table of Contents
Challenge 1: Automate record creation
Challenge 2: Synchronize Salesforce data with an external system
Challenge 3: Schedule synchronization
Challenge 4: Test automation logic
Challenge 5: Test callout logic
Challenge 6: Test scheduling logic

Superbadge Apex Specialist looks good on Resume, and they prove worth it as well. You should definitely complete the task on your own and you can get all the help. All these codes are working 100% and run smoothly to help you achieve the below shiny badge. I had mine and wrote this while doing so…

Free Salesforce Exam Coupon Codes for 2022

Superbadge Apex Specialist Full Solutions - Salesforce Handle (1)

Apex Specialist

What You’ll Be Doing to Earn This Superbadge

  1. Automate record creation using Apex triggers
  2. Synchronize Salesforce data with an external system using asynchronous REST callouts
  3. Schedule synchronization using Apex code
  4. Test automation logic to confirm Apex trigger side effects
  5. Test integration logic using callout mocks
  6. Test scheduling logic to confirm action gets queued

Challenge 1: Automate record creation

Stuck on Superbadge Apex Specialist Step 1?

Change the labels for Case and Product To Maintenance Request and Equipment respectively.

ChangethelabelsforStandard Objectsand Fields in Salesforce
Go to Setup -> Customize -> Tab Names andLabels->RenameTabs andLabels.
Choose the Tab (orObject) you want torenameand clickEdit.

Change the Codes
Go to Developer console and edit the Apex class and related triggers for below:

public with sharing class MaintenanceRequestHelper { public static void updateWorkOrders(List<Case> caseList) { List<case> newCases = new List<Case>(); Map<String,Integer> result=getDueDate(caseList); for(Case c : caseList){ if(c.status=='closed') if(c.type=='Repair' || c.type=='Routine Maintenance'){ Case newCase = new Case(); newCase.Status='New'; newCase.Origin='web'; newCase.Type='Routine Maintenance'; newCase.Subject='Routine Maintenance of Vehicle'; newCase.Vehicle__c=c.Vehicle__c; newCase.Equipment__c=c.Equipment__c; newCase.Date_Reported__c=Date.today(); if(result.get(c.Id)!=null) newCase.Date_Due__c=Date.today()+result.get(c.Id); else newCase.Date_Due__c=Date.today(); newCases.add(newCase); } } insert newCases; } // public static Map<String,Integer> getDueDate(List<case> CaseIDs){ Map<String,Integer> result = new Map<String,Integer>(); Map<Id, case> caseKeys = new Map<Id, case> (CaseIDs); List<AggregateResult> wpc=[select Maintenance_Request__r.ID cID,min(Equipment__r.Maintenance_Cycle__c)cycle from Work_Part__c where Maintenance_Request__r.ID in :caseKeys.keySet() group by Maintenance_Request__r.ID ]; for(AggregateResult res :wpc){ Integer addDays=0; if(res.get('cycle')!=null) addDays+=Integer.valueOf(res.get('cycle')); result.put((String)res.get('cID'),addDays); } return result;}}
trigger MaintenanceRequest on Case (before update, after update) { // ToDo: Call MaintenanceRequestHelper.updateWorkOrders if(Trigger.isAfter) MaintenanceRequestHelper.updateWorkOrders(Trigger.New); }

Challenge 2: Synchronize Salesforce data with an external system

Issue with Superbadge Apex Specialist Step 2?

public with sharing class WarehouseCalloutService { private static final String WAREHOUSE_URL = 'https://th-superbadge-apex.herokuapp.com/equipment'; @future(callout=true) public static void runWarehouseEquipmentSync() { //ToDo: complete this method to make the callout (using @future) to the // REST endpoint and update equipment on hand. HttpResponse response = getResponse(); if(response.getStatusCode() == 200) { List<Product2> results = getProductList(response); //get list of products from Http callout response if(results.size() >0) upsert results Warehouse_SKU__c; //Upsert the products in your org based on the external ID SKU } } //Get the product list from the external link public static List<Product2> getProductList(HttpResponse response) { List<Object> externalProducts = (List<Object>) JSON.deserializeUntyped(response.getBody()); //desrialize the json response List<Product2> newProducts = new List<Product2>(); for(Object p : externalProducts) { Map<String, Object> productMap = (Map<String, Object>) p; Product2 pr = new Product2(); //Map the fields in the response to the appropriate fields in the Equipment object pr.Replacement_Part__c = (Boolean)productMap.get('replacement'); pr.Cost__c = (Integer)productMap.get('cost'); pr.Current_Inventory__c = (Integer)productMap.get('quantity'); pr.Lifespan_Months__c = (Integer)productMap.get('lifespan') ; pr.Maintenance_Cycle__c = (Integer)productMap.get('maintenanceperiod'); pr.Warehouse_SKU__c = (String)productMap.get('sku'); pr.ProductCode = (String)productMap.get('_id'); pr.Name = (String)productMap.get('name'); newProducts.add(pr); } return newProducts; } // Send Http GET request and receive Http response public static HttpResponse getResponse() { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint(WAREHOUSE_URL); request.setMethod('GET'); HttpResponse response = http.send(request); return response; } }

Execute below in the anonymous window :

WarehouseCalloutService.runWarehouseEquipmentSync(); 

Wait for a minute and run it twice maybe before checking challenges.

Challenge 3: Schedule synchronization

Help with Superbadge Apex Specialist Step 3?

Go to Setup > Apex Classes > Schedule a job like below:

Superbadge Apex Specialist Full Solutions - Salesforce Handle (2)

Edit the following in the Developer console

global class WarehouseSyncSchedule implements Schedulable{ // implement scheduled code here global void execute (SchedulableContext sc){ WarehouseCalloutService.runWarehouseEquipmentSync(); //optional this can be done by debug mode String sch = '00 00 01 * * ?';//on 1 pm System.schedule('WarehouseSyncScheduleTest', sch, new WarehouseSyncSchedule()); }}

And execute in the anonymous window below:

WarehouseSyncSchedule scheduleInventoryCheck();

Read More: Salesforce Interview Questions and Answers We Swear By!

Challenge 4: Test automation logic

Stuck on Superbadge Apex Specialist Step 4?

Modifications to the below Apex Classes as below.

trigger MaintenanceRequest on Case (before update, after update) { if(Trigger.isUpdate && Trigger.isAfter) MaintenanceRequestHelper.updateWorkOrders(Trigger.New);}
@IsTestprivate class InstallationTests { private static final String STRING_TEST = 'TEST'; private static final String NEW_STATUS = 'New'; private static final String WORKING = 'Working'; private static final String CLOSED = 'Closed'; private static final String REPAIR = 'Repair'; private static final String REQUEST_ORIGIN = 'Web'; private static final String REQUEST_TYPE = 'Routine Maintenance'; private static final String REQUEST_SUBJECT = 'AMC Spirit'; public static String CRON_EXP = '0 0 1 * * ?'; static testmethod void testMaintenanceRequestNegative() { Vehicle__c vehicle = createVehicle(); insert vehicle; Id vehicleId = vehicle.Id; Product2 equipment = createEquipment(); insert equipment; Id equipmentId = equipment.Id; Case r = createMaintenanceRequest(vehicleId, equipmentId); insert r; Work_Part__c w = createWorkPart(equipmentId, r.Id); insert w; Test.startTest(); r.Status = WORKING; update r; Test.stopTest(); List<case> allRequest = [SELECT Id FROM Case]; Work_Part__c workPart = [SELECT Id FROM Work_Part__c WHERE Maintenance_Request__c =: r.Id]; System.assert(workPart != null); System.assert(allRequest.size() == 1); } static testmethod void testWarehouseSync() { Test.setMock(HttpCalloutMock.class, new WarehouseCalloutServiceMock()); Test.startTest(); String jobId = System.schedule('WarehouseSyncSchedule', CRON_EXP, new WarehouseSyncSchedule()); CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId]; System.assertEquals(CRON_EXP, ct.CronExpression); System.assertEquals(0, ct.TimesTriggered); Test.stopTest(); } private static Vehicle__c createVehicle() { Vehicle__c v = new Vehicle__c(Name = STRING_TEST); return v; } private static Product2 createEquipment() { Product2 p = new Product2(Name = STRING_TEST, Lifespan_Months__c = 10, Maintenance_Cycle__c = 10, Replacement_Part__c = true); return p; } private static Case createMaintenanceRequest(Id vehicleId, Id equipmentId) { Case c = new Case(Type = REPAIR, Status = NEW_STATUS, Origin = REQUEST_ORIGIN, Subject = REQUEST_SUBJECT, Equipment__c = equipmentId, Vehicle__c = vehicleId); return c; } private static Work_Part__c createWorkPart(Id equipmentId, Id requestId) { Work_Part__c wp = new Work_Part__c(Equipment__c = equipmentId, Maintenance_Request__c = requestId); return wp; }}
public with sharing class MaintenanceRequestHelper {public static void updateWorkOrders(List<case> caseList) {List<case> newCases = new List<case>();Map<String,Integer> result=getDueDate(caseList);for(Case c : caseList){if(c.status=='closed')if(c.type=='Repair' || c.type=='Routine Maintenance'){Case newCase = new Case();newCase.Status='New';newCase.Origin='web';newCase.Type='Routine Maintenance';newCase.Subject='Routine Maintenance of Vehicle';newCase.Vehicle__c=c.Vehicle__c;newCase.Equipment__c=c.Equipment__c;newCase.Date_Reported__c=Date.today();if(result.get(c.Id)!=null)newCase.Date_Due__c=Date.today()+result.get(c.Id);elsenewCase.Date_Due__c=Date.today();newCases.add(newCase);}}insert newCases;}//public static Map<String,Integer> getDueDate(List<case> CaseIDs){Map<String,Integer> result = new Map<String,Integer>();Map<Id, case> caseKeys = new Map<Id, case> (CaseIDs);List<aggregateresult> wpc=[select Maintenance_Request__r.ID cID,min(Equipment__r.Maintenance_Cycle__c)cyclefrom Work_Part__c where Maintenance_Request__r.ID in :caseKeys.keySet() group by Maintenance_Request__r.ID ];for(AggregateResult res :wpc){Integer addDays=0;if(res.get('cycle')!=null)addDays+=Integer.valueOf(res.get('cycle'));result.put((String)res.get('cID'),addDays);}return result;}}
@isTestpublic class MaintenanceRequestTest { static List<case> caseList1 = new List<case>(); static List<product2> prodList = new List<product2>(); static List<work_part__c> wpList = new List<work_part__c>();@testSetup static void getData(){ caseList1= CreateData( 300,3,3,'Repair'); } public static List<case> CreateData( Integer numOfcase, Integer numofProd, Integer numofVehicle, String type){ List<case> caseList = new List<case>(); //Create Vehicle Vehicle__c vc = new Vehicle__c(); vc.name='Test Vehicle'; upsert vc; //Create Equiment for(Integer i=0;i<numofProd;i++){ Product2 prod = new Product2(); prod.Name='Test Product'+i; if(i!=0) prod.Maintenance_Cycle__c=i; prod.Replacement_Part__c=true; prodList.add(prod); } upsert prodlist; //Create Case for(Integer i=0;i< numOfcase;i++){ Case newCase = new Case(); newCase.Status='New'; newCase.Origin='web'; if( math.mod(i, 2) ==0) newCase.Type='Routine Maintenance'; else newCase.Type='Repair'; newCase.Subject='Routine Maintenance of Vehicle' +i; newCase.Vehicle__c=vc.Id; if(i<numofProd) newCase.Equipment__c=prodList.get(i).ID; else newCase.Equipment__c=prodList.get(0).ID; caseList.add(newCase); } upsert caseList; for(Integer i=0;i<numofProd;i++){ Work_Part__c wp = new Work_Part__c(); wp.Equipment__c =prodlist.get(i).Id ; wp.Maintenance_Request__c=caseList.get(i).id; wplist.add(wp) ; } upsert wplist; return caseList; } public static testmethod void testMaintenanceHelper(){ Test.startTest(); getData(); for(Case cas: caseList1) cas.Status ='Closed'; update caseList1; Test.stopTest(); }}

Challenge 5: Test callout logic

Issue with Superbadge Apex Specialist Step 5?

Modify the Apex Classes as below, save and run all.

@IsTestprivate class WarehouseCalloutServiceTest { // implement your mock callout test here @isTest static void testWareHouseCallout(){ Test.setMock(HttpCalloutMock.class, new WarehouseCalloutServiceMock()); WarehouseCalloutService.runWarehouseEquipmentSync(); }}
@isTestpublic class WarehouseCalloutServiceMock implements HTTPCalloutMock { // implement http mock callout public HTTPResponse respond (HttpRequest request){ 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"},{"_id":"55d66226726b611100aaf742","replacement":true,"quantity":183,"name":"Cooling Fan","maintenanceperiod":0,"lifespan":0,"cost":300,"sku":"100004"},{"_id":"55d66226726b611100aaf743","replacement":true,"quantity":143,"name":"Fuse 20A","maintenanceperiod":0,"lifespan":0,"cost":22,"sku":"100005"}]'); response.setStatusCode(200); return response; }}

Challenge 6: Test scheduling logic

Stuck on Superbadge Apex Specialist Step 6?

Modify as below

@isTestprivate class WarehouseSyncScheduleTest { public static String CRON_EXP = '0 0 0 15 3 ? 2022'; static testmethod void testjob(){ MaintenanceRequestTest.CreateData( 5,2,2,'Repair'); Test.startTest(); Test.setMock(HttpCalloutMock.class, new WarehouseCalloutServiceMock()); String joBID= System.schedule('TestScheduleJob', CRON_EXP, new WarehouseSyncSchedule()); // List<Case> caselist = [Select count(id) from case where case] Test.stopTest(); }}

Hope this helps!
Looking For? Superbadge Process Automation Specialist – Full Solutions

Share to someone in the Trailhead Community. Let’s grow together.

Need help on specific errors? Start a discussion in the forum to get straight-up answers.

Let the universe renounce some goodness to you 😇

Read More: Salesforce Interview Questions and Answers We Swear By!

Superbadge Apex Specialist Full Solutions - Salesforce Handle (2024)

FAQs

How do you beat the security specialist in SuperBadge? ›

Security Specialist SuperBadge
  1. Create a First profile Field Sales user.
  2. Create a Second profile Field Sales user.
  3. Step3: ...
  4. Install the Trailhead Security superbadge managed package (package ID: 04t36000000jWht)
  5. Create Roles name:
  6. Create user : Goto setup, and find on Quick search box users, click on Users.

Which package needs to be installed as a prerequisite for Apex specialist? ›

Set Up Development Org

The package you will install has some custom lightning components that only show when My Domain is deployed. Install this unlocked package (package ID: 04t6g000008av9iAAA). This package contains metadata you'll use to complete this challenge.

How do Superbadges relate to the trailhead credentials and certification program? ›

Superbadges help you to gain the knowledge that you need to clear the certifications. Superbadges are not mandatory before you can appear (and clear) the certifications.

How does the trailhead certification agreement relate to sharing a Superbadge solution or reusing elements of another trailblazer's work? ›

Salesforce Credentialing Program participants are prohibited from: Sharing, using, or requesting configured solutions, elements of solutions, metadata, or packages to solve any superbadge challenge. Attempting to share or transfer any Salesforce credential. Completing an exam or superbadge on another individual's ...

What are types of asynchronous apex? ›

Types of Asynchronous Apex:

Batch Apex : This is used to run large jobs which contains millions of records. Queue able Apex : These are also like future methods but has an ability to chain jobs with a class. Scheduled Apex : These are scheduled to run at a specific time.

How do I complete a Superbadge in Salesforce? ›

Apply Your Skills and Level Up

Unlock a superbadge by completing the requisite badges. Then, use the skills you've learned to solve real-world, hands-on challenges.

What is Superbadge Salesforce? ›

Superbadges are skill-based, domain-level credentials that ask you to show your Salesforce expertise by solving complex, real-world-inspired challenges that businesses face every day. To earn a superbadge, you must first unlock it by completing prerequisite Trailhead badges on core concepts.

What are possible consequences of violations of the trailhead certification agreement? ›

Cancellation of upcoming and in progress certification exams. Suspension from earning or revocation of Salesforce Credentials. Removal from the Salesforce Credentialing Program and/or the Trailblazer Community.

Is Oracle Apex in demand? ›

Demand For Low-code/No-code Driving Strong Momentum For Oracle APEX In Asia. An increasing number of businesses in Asia are turning to Oracle to gain the benefits of using its new low-code service for developing and deploying data-driven, enterprise applications quickly and easily, Oracle Application Express (APEX).

Does Oracle APEX cost money? ›

There are no extra costs based on the number of APEX apps, workspaces, developer accounts, or application end users. Data transfer into and out of the service (ingress and egress) is included at no extra cost.

How do I run a Queueable class from the developer console? ›

To add this class as a job on the queue, call this method: ID jobID = System. enqueueJob(new AsyncExecutionExample()); After you submit your queueable class for execution, the job is added to the queue and will be processed when system resources become available.

Can you put Superbadges on resume? ›

Superbadges can easily be added to your LinkedIn or you can include them on your resume as a skill-boosting shot over other candidates. Besides the benefits you can get from a hiring perspective, Superbadges are required now for at least the Platform Developer II exam.

Should I put Superbadges on my resume? ›

Acts as a Resume Builder - Superbadges can be added to your resume to help you stand out among peers as well as demonstrate to recruiters and hiring managers that you have real-world experience using these skills. Not only do they help you stand apart, but they allow you to be confident in your advertised abilities.

Can I put Trailhead on my resume? ›

In the Certifications section (under Accomplishments), you can list out individual Badges or Superbadges you've completed, for example the Security Specialist Superbadge, and include your Trailhead profile link as the 'Certification URL' for proof.

Can we cheat in Salesforce online exam? ›

So, you cannot cheat on the Salesforce Admin exam. Even if you try to cheat through exam dumps in one of your various certification exams, Salesforce will terminate your certifications. You will not be allowed to obtain Salesforce credentials in the future.

What is a good Trailhead score? ›

Trailhead is based on gamification; users achieve badges (etc.) in order to level up through the ranks, with 'Ranger' being the highest. Becoming a Trailhead Ranger requires 100 badges and 50,000 points, and so, is considered a great achievement for Trailblazers.

Can you retake Superbadges? ›

While you can retake challenges for badges and projects, you cannot do so for Superbadges.

Can we call Queueable from future method? ›

Future methods cannot be monitored, but queueable apex can be monitored using the job id which is returned by System. enqueueJob() In execution cycle, you cannot call from one future method to another future method. Its achieved inqueueable class by using the Chaining Jobs.

How do you call a future method in Apex? ›

To define a future method, simply annotate it with the future annotation, as follows. Methods with the future annotation must be static methods, and can only return a void type. The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types.

Can we call future method from batch class? ›

we cannot call a future from another future or batch apex. The limit on future method for single apex invocation is 50.

› trailhead ›

According to the latest Glassdoor report on jobs with the best career opportunities, Salesforce Developer is second from the top! These two Trailhead superbadge...
What You'll Be Doing to Earn This Superbadge. Debug and troubleshoot Apex code; Develop Apex Code that will scale to large data sets; Develop custom interfa...
If you haven't already heard about Trailhead, this is the gamification platform that Salesforce provides for all of its users to learn how to use Salesforce...

How do I fix this Schedulable class has jobs pending or in progress? ›

If you know the scheduled jobs that are related to this class or its dependent classes, you can abort the jobs manually from Setup | Jobs | Scheduled Jobs.

Where are Apex triggers stored on the platform? ›

Apex triggers are stored as metadata in the application under the object with which they are associated.

How do I delete a scheduled job in Salesforce? ›

The scheduled or future Apex job should get deleted.
...
To Delete the job from UI:
  1. Go to Setup.
  2. Search "Scheduled" in the quick find box.
  3. Click "Scheduled Jobs"
  4. Click "Del" link beside the scheduled job that you wanted to delete.
  5. Click the "Ok" on the prompt.
27 Jun 2022

How do I run a Queueable apex? ›

To add this class as a job on the queue, call this method: ID jobID = System. enqueueJob(new AsyncExecutionExample()); After you submit your queueable class for execution, the job is added to the queue and will be processed when system resources become available.

How do you check a scheduled job is running or not in Salesforce? ›

To view this page, from Setup, enter Scheduled Jobs in the Quick Find box, then select Scheduled Jobs. Depending on your permissions, you can perform some or all of the following actions. Click Del to permanently delete all instances of a scheduled job.

How do I query a scheduled job in Salesforce? ›

Go to setup->monitor->jobs->scheduled jobs, and you'll see a list of all scheduled jobs.

How do I terminate scheduled jobs in Apex? ›

To Delete the job from UI:

Go to Setup. Search "Scheduled" in the quick find box. Click "Scheduled Jobs" Click "Del" link beside the scheduled job that you wanted to delete.

Can a trigger call a batch class? ›

Batch Apex can be invoked using an Apex trigger. But the trigger should not add more batch jobs than the limit.

Can we call one trigger from another trigger in Salesforce? ›

If trigger starts working from another trigger, they are executed in same transaction. So as you can see, they both share limits in one transaction.

Can we write DML in trigger? ›

DML triggers can be used to enforce business rules and data integrity, query other tables, and include complex Transact-SQL statements. The trigger and the statement that fires it are treated as a single transaction, which can be rolled back from within the trigger.

How do I stop Apex jobs in Salesforce? ›

To abort long running batch, future or scheduled Apex jobs, you may use System. abortJob() from the Developer Console (execute anonymous window) and pass the job id to this method.

How do I run Apex manually in Salesforce? ›

From Setup, enter Apex Classes in the Quick Find box, select Apex Classes, and then click Schedule Apex. Specify the name of a class that you want to schedule. Specify how often the Apex class is to run. For Weekly—specify one or more days of the week the job is to run (such as Monday and Wednesday).

How do I stop a batch job in Salesforce? ›

When we are using the Batch Apex, we must implement the Salesforce-provided interface Database. Batchable, and then invoke the class programmatically. To monitor or stop the execution of the batch Apex Batch job, go to Setup → Monitoring → Apex Jobs or Jobs → Apex Jobs.

Can we call future method from Queueable? ›

As per the documentation we can only call 1 future from Queueable context.

Can I call Queueable from trigger? ›

Chaining Queueable Jobs from an Apex Trigger on a specific Object is one more approach. The Apex Trigger enqueues a new Queueable Job, in case there are no jobs of the same type in the progress of execution and there are items for processing.

Can we call future method from scheduled apex? ›

we cannot call a future from another future or batch apex. The limit on future method for single apex invocation is 50.

Top Articles
Latest Posts
Article information

Author: Pres. Lawanda Wiegand

Last Updated:

Views: 6086

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Pres. Lawanda Wiegand

Birthday: 1993-01-10

Address: Suite 391 6963 Ullrich Shore, Bellefort, WI 01350-7893

Phone: +6806610432415

Job: Dynamic Manufacturing Assistant

Hobby: amateur radio, Taekwondo, Wood carving, Parkour, Skateboarding, Running, Rafting

Introduction: My name is Pres. Lawanda Wiegand, I am a inquisitive, helpful, glamorous, cheerful, open, clever, innocent person who loves writing and wants to share my knowledge and understanding with you.